finally
This commit is contained in:
parent
96d69b91a6
commit
d05f1f9695
@ -113,13 +113,11 @@ namespace IceCreamShopBusinessLogic.BusinessLogic
|
||||
"Email:{ Email}. Password:{ Password}. Id: { Id} ", model.ClientFIO, model.Email, model.Password, model.Id);
|
||||
var element = _clientStorage.GetElement(new ClientSearchModel
|
||||
{
|
||||
ClientFIO = model.ClientFIO,
|
||||
Email = model.Email,
|
||||
Password = model.Password
|
||||
Email = model.Email,
|
||||
});
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Клиент с таким названием уже есть");
|
||||
throw new InvalidOperationException("Клиент с таким лоигном уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ namespace IceCreamShopClientApp.Controllers
|
||||
[HttpGet]
|
||||
public IActionResult Create()
|
||||
{
|
||||
ViewBag.Products =
|
||||
ViewBag.IceCreams =
|
||||
APIClient.GetRequest<List<IceCreamViewModel>>("api/main/geticecreamlist");
|
||||
return View();
|
||||
}
|
||||
@ -142,9 +142,9 @@ namespace IceCreamShopClientApp.Controllers
|
||||
public double Calc(int count, int iceCream)
|
||||
{
|
||||
var _iceCream =
|
||||
APIClient.GetRequest<IceCreamViewModel>($"api/main/geticecream?iceCreamId={iceCream}"
|
||||
APIClient.GetRequest<IceCreamViewModel>($"api/main/geticecream?icecreamid={iceCream}"
|
||||
);
|
||||
return count * (_iceCream?.Price ?? 1);
|
||||
return Math.Round(count * (_iceCream?.Price ?? 1), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
@{
|
||||
ViewData["Title"] = "Create";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Создание заказа</h2>
|
||||
</div>
|
||||
@ -8,7 +9,7 @@
|
||||
<div class="row">
|
||||
<div class="col-4">Мороженное:</div>
|
||||
<div class="col-8">
|
||||
<select id="product" name="product" class="form-control" aspitems="@(new SelectList(@ViewBag.IceCreams,"Id", "IceCreamName"))"></select>
|
||||
<select id="icecream" name="icecream" class="form-control" asp-items="@(new SelectList(@ViewBag.IceCreams,"Id", "IceCreamName"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
@ -32,20 +33,21 @@ btn-primary" />
|
||||
</div>
|
||||
</form>
|
||||
<script>
|
||||
$('#product').on('change', function () {
|
||||
$('#icecream').on('change', function () {
|
||||
check();
|
||||
});
|
||||
$('#count').on('change', function () {
|
||||
check();
|
||||
});
|
||||
|
||||
function check() {
|
||||
var count = $('#count').val();
|
||||
var product = $('#product').val();
|
||||
if (count && product) {
|
||||
var icecream = $('#icecream').val();
|
||||
if (count && icecream) {
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
url: "/Home/Calc",
|
||||
data: { count: count, product: product },
|
||||
data: { count: count, icecream: icecream },
|
||||
success: function (result) {
|
||||
$("#sum").val(result);
|
||||
}
|
||||
|
@ -1,6 +1,28 @@
|
||||
@{
|
||||
ViewData["Title"] = "Privacy Policy";
|
||||
}
|
||||
<h1>@ViewData["Title"]</h1>
|
||||
@using IceCreamShopContracts.ViewModels
|
||||
|
||||
<p>Use this page to detail your site's privacy policy.</p>
|
||||
@model ClientViewModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Privacy Policy";
|
||||
}
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Личные данные</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">Логин:</div>
|
||||
<div class="col-8"><input type="text" name="login" value="@Model.Email"/></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Пароль:</div>
|
||||
<div class="col-8"><input type="password" name="password" value="@Model.Password"/></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">ФИО:</div>
|
||||
<div class="col-8"><input type="text" name="fio" value="@Model.ClientFIO"/></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4"><input type="submit" value="Сохранить" class="btn btn-primary" /></div>
|
||||
</div>
|
||||
</form>
|
@ -1,4 +1,8 @@
|
||||
<div class="text-center">
|
||||
@{
|
||||
ViewData["Title"] = "Register";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Регистрация</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
|
@ -6,5 +6,5 @@
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"IPAddress": "http://localhost:7130/"
|
||||
"IPAddress": "http://localhost:5189"
|
||||
}
|
||||
|
@ -38,15 +38,16 @@ namespace IceCreamShopDatabaseImplement.Implements
|
||||
}
|
||||
public ClientViewModel? GetElement(ClientSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.ClientFIO) &&
|
||||
!model.Id.HasValue)
|
||||
if (string.IsNullOrEmpty(model.ClientFIO) && string.IsNullOrEmpty(model.Email) &&
|
||||
!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new IceCreamShopDataBase();
|
||||
return context.Clients
|
||||
.FirstOrDefault(x => (string.IsNullOrEmpty(model.ClientFIO) || x.ClientFIO == model.ClientFIO) &&
|
||||
(!model.Id.HasValue || x.Id == model.Id))
|
||||
(!model.Id.HasValue || x.Id == model.Id) && (string.IsNullOrEmpty(model.Email) || x.Email == model.Email) &&
|
||||
(string.IsNullOrEmpty(model.Password) || x.Password == model.Password))
|
||||
?.GetViewModel;
|
||||
}
|
||||
public ClientViewModel? Insert(ClientBindingModel model)
|
||||
|
@ -18,7 +18,7 @@ namespace IceCreamShopDatabaseImplement.Implements
|
||||
{
|
||||
using var context = new IceCreamShopDataBase();
|
||||
return context.Orders.Include(x => x.IceCream)
|
||||
.Select(x => x.GetViewModel)
|
||||
.Include(x => x.Client).Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||
@ -27,7 +27,7 @@ namespace IceCreamShopDatabaseImplement.Implements
|
||||
using var context = new IceCreamShopDataBase();
|
||||
return context.Orders
|
||||
.Include(x => x.IceCream)
|
||||
.Where(x => (
|
||||
.Include(x => x.Client).Where(x => (
|
||||
(!model.Id.HasValue || x.Id == model.Id) &&
|
||||
(!model.DateFrom.HasValue || x.DateCreate >= model.DateFrom) &&
|
||||
(!model.DateTo.HasValue || x.DateCreate <= model.DateTo)
|
||||
@ -45,7 +45,7 @@ namespace IceCreamShopDatabaseImplement.Implements
|
||||
return null;
|
||||
}
|
||||
using var context = new IceCreamShopDataBase();
|
||||
return context.Orders.Include(x => x.IceCream).FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
||||
return context.Orders.Include(x => x.IceCream).Include(x=> x.Client).FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
||||
}
|
||||
public OrderViewModel? Insert(OrderBindingModel model)
|
||||
{
|
||||
@ -62,7 +62,7 @@ namespace IceCreamShopDatabaseImplement.Implements
|
||||
public OrderViewModel? Update(OrderBindingModel model)
|
||||
{
|
||||
using var context = new IceCreamShopDataBase();
|
||||
var order = context.Orders.Include(x => x.IceCream).FirstOrDefault(x => x.Id ==
|
||||
var order = context.Orders.Include(x => x.IceCream).Include(x => x.Client).FirstOrDefault(x => x.Id ==
|
||||
model.Id);
|
||||
if (order == null)
|
||||
{
|
||||
|
@ -17,7 +17,7 @@ namespace IceCreamShopDatabaseImplement.Migrations
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.3")
|
||||
.HasAnnotation("Version", "7.0.3")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
@ -45,8 +45,9 @@ namespace IceCreamShopDatabaseImplement.Models
|
||||
DateImplement = model.DateImplement,
|
||||
IceCreamId = model.IceCreamId,
|
||||
IceCream = context.IceCreams.FirstOrDefault(x => x.Id == model.IceCreamId),
|
||||
ClientId = model.ClientId
|
||||
};
|
||||
ClientId = model.ClientId,
|
||||
Client = context.Clients.FirstOrDefault(x => x.Id == model.ClientId),
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(OrderBindingModel? model)
|
||||
|
@ -40,15 +40,12 @@ namespace IceCreamShopFileImplement.Implements
|
||||
}
|
||||
public ClientViewModel? GetElement(ClientSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue && string.IsNullOrEmpty(model.ClientFIO))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return source.Clients
|
||||
.FirstOrDefault(x => (string.IsNullOrEmpty(model.ClientFIO) || x.ClientFIO == model.ClientFIO) &&
|
||||
(!model.Id.HasValue || x.Id == model.Id))
|
||||
?.GetViewModel;
|
||||
}
|
||||
return source.Clients
|
||||
.FirstOrDefault(x => (string.IsNullOrEmpty(model.ClientFIO) || x.ClientFIO == model.ClientFIO) &&
|
||||
(!model.Id.HasValue || x.Id == model.Id) && (string.IsNullOrEmpty(model.Email) || x.Email == model.Email) &&
|
||||
(string.IsNullOrEmpty(model.Password) || x.Password == model.Password))
|
||||
?.GetViewModel;
|
||||
}
|
||||
public ClientViewModel? Insert(ClientBindingModel model)
|
||||
{
|
||||
model.Id = source.Clients.Count > 0 ? source.Clients.Max(x =>
|
||||
|
@ -46,15 +46,11 @@ namespace IceCreamShopListImplement.Implements
|
||||
}
|
||||
public ClientViewModel? GetElement(ClientSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.ClientFIO) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
foreach (var client in _source.Clients)
|
||||
{
|
||||
if ((!string.IsNullOrEmpty(model.ClientFIO) &&
|
||||
client.ClientFIO == model.ClientFIO) ||
|
||||
(model.Id.HasValue && client.Id == model.Id))
|
||||
if ((string.IsNullOrEmpty(model.ClientFIO) || client.ClientFIO == model.ClientFIO) &&
|
||||
(!model.Id.HasValue || client.Id == model.Id) && (string.IsNullOrEmpty(model.Email) || client.Email == model.Email) &&
|
||||
(string.IsNullOrEmpty(model.Password) || client.Password == model.Password))
|
||||
{
|
||||
return client.GetViewModel;
|
||||
}
|
||||
|
@ -122,6 +122,8 @@ namespace IceCreamShopListImplement.Implements
|
||||
model.ClientFIO = client.ClientFIO;
|
||||
return model;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,7 +11,9 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="log4net.config" />
|
||||
<None Include="log4net.config">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@ -22,6 +24,8 @@
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\IceCreamShopBusinessLogic\IceCreamShopBusinessLogic.csproj" />
|
||||
<ProjectReference Include="..\IceCreamShopDatabaseImplement\IceCreamShopDatabaseImplement.csproj" />
|
||||
<ProjectReference Include="..\IceCreamShopFileImplement\IceCreamShopFileImplement.csproj" />
|
||||
<ProjectReference Include="..\IceCreamShopListImplement\IceCreamShopListImplement.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
Loading…
Reference in New Issue
Block a user