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);
|
"Email:{ Email}. Password:{ Password}. Id: { Id} ", model.ClientFIO, model.Email, model.Password, model.Id);
|
||||||
var element = _clientStorage.GetElement(new ClientSearchModel
|
var element = _clientStorage.GetElement(new ClientSearchModel
|
||||||
{
|
{
|
||||||
ClientFIO = model.ClientFIO,
|
|
||||||
Email = model.Email,
|
Email = model.Email,
|
||||||
Password = model.Password
|
|
||||||
});
|
});
|
||||||
if (element != null && element.Id != model.Id)
|
if (element != null && element.Id != model.Id)
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException("Клиент с таким названием уже есть");
|
throw new InvalidOperationException("Клиент с таким лоигном уже есть");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,7 @@ namespace IceCreamShopClientApp.Controllers
|
|||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult Create()
|
public IActionResult Create()
|
||||||
{
|
{
|
||||||
ViewBag.Products =
|
ViewBag.IceCreams =
|
||||||
APIClient.GetRequest<List<IceCreamViewModel>>("api/main/geticecreamlist");
|
APIClient.GetRequest<List<IceCreamViewModel>>("api/main/geticecreamlist");
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
@ -142,9 +142,9 @@ namespace IceCreamShopClientApp.Controllers
|
|||||||
public double Calc(int count, int iceCream)
|
public double Calc(int count, int iceCream)
|
||||||
{
|
{
|
||||||
var _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";
|
ViewData["Title"] = "Create";
|
||||||
}
|
}
|
||||||
|
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<h2 class="display-4">Создание заказа</h2>
|
<h2 class="display-4">Создание заказа</h2>
|
||||||
</div>
|
</div>
|
||||||
@ -8,7 +9,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">Мороженное:</div>
|
<div class="col-4">Мороженное:</div>
|
||||||
<div class="col-8">
|
<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>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@ -32,20 +33,21 @@ btn-primary" />
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<script>
|
<script>
|
||||||
$('#product').on('change', function () {
|
$('#icecream').on('change', function () {
|
||||||
check();
|
check();
|
||||||
});
|
});
|
||||||
$('#count').on('change', function () {
|
$('#count').on('change', function () {
|
||||||
check();
|
check();
|
||||||
});
|
});
|
||||||
|
|
||||||
function check() {
|
function check() {
|
||||||
var count = $('#count').val();
|
var count = $('#count').val();
|
||||||
var product = $('#product').val();
|
var icecream = $('#icecream').val();
|
||||||
if (count && product) {
|
if (count && icecream) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method: "POST",
|
method: "POST",
|
||||||
url: "/Home/Calc",
|
url: "/Home/Calc",
|
||||||
data: { count: count, product: product },
|
data: { count: count, icecream: icecream },
|
||||||
success: function (result) {
|
success: function (result) {
|
||||||
$("#sum").val(result);
|
$("#sum").val(result);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,28 @@
|
|||||||
@{
|
@using IceCreamShopContracts.ViewModels
|
||||||
ViewData["Title"] = "Privacy Policy";
|
|
||||||
}
|
|
||||||
<h1>@ViewData["Title"]</h1>
|
|
||||||
|
|
||||||
<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>
|
<h2 class="display-4">Регистрация</h2>
|
||||||
</div>
|
</div>
|
||||||
<form method="post">
|
<form method="post">
|
||||||
|
@ -6,5 +6,5 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"AllowedHosts": "*",
|
"AllowedHosts": "*",
|
||||||
"IPAddress": "http://localhost:7130/"
|
"IPAddress": "http://localhost:5189"
|
||||||
}
|
}
|
||||||
|
@ -38,15 +38,16 @@ namespace IceCreamShopDatabaseImplement.Implements
|
|||||||
}
|
}
|
||||||
public ClientViewModel? GetElement(ClientSearchModel model)
|
public ClientViewModel? GetElement(ClientSearchModel model)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(model.ClientFIO) &&
|
if (string.IsNullOrEmpty(model.ClientFIO) && string.IsNullOrEmpty(model.Email) &&
|
||||||
!model.Id.HasValue)
|
!model.Id.HasValue)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
using var context = new IceCreamShopDataBase();
|
using var context = new IceCreamShopDataBase();
|
||||||
return context.Clients
|
return context.Clients
|
||||||
.FirstOrDefault(x => (string.IsNullOrEmpty(model.ClientFIO) || x.ClientFIO == model.ClientFIO) &&
|
.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;
|
?.GetViewModel;
|
||||||
}
|
}
|
||||||
public ClientViewModel? Insert(ClientBindingModel model)
|
public ClientViewModel? Insert(ClientBindingModel model)
|
||||||
|
@ -18,7 +18,7 @@ namespace IceCreamShopDatabaseImplement.Implements
|
|||||||
{
|
{
|
||||||
using var context = new IceCreamShopDataBase();
|
using var context = new IceCreamShopDataBase();
|
||||||
return context.Orders.Include(x => x.IceCream)
|
return context.Orders.Include(x => x.IceCream)
|
||||||
.Select(x => x.GetViewModel)
|
.Include(x => x.Client).Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||||
@ -27,7 +27,7 @@ namespace IceCreamShopDatabaseImplement.Implements
|
|||||||
using var context = new IceCreamShopDataBase();
|
using var context = new IceCreamShopDataBase();
|
||||||
return context.Orders
|
return context.Orders
|
||||||
.Include(x => x.IceCream)
|
.Include(x => x.IceCream)
|
||||||
.Where(x => (
|
.Include(x => x.Client).Where(x => (
|
||||||
(!model.Id.HasValue || x.Id == model.Id) &&
|
(!model.Id.HasValue || x.Id == model.Id) &&
|
||||||
(!model.DateFrom.HasValue || x.DateCreate >= model.DateFrom) &&
|
(!model.DateFrom.HasValue || x.DateCreate >= model.DateFrom) &&
|
||||||
(!model.DateTo.HasValue || x.DateCreate <= model.DateTo)
|
(!model.DateTo.HasValue || x.DateCreate <= model.DateTo)
|
||||||
@ -45,7 +45,7 @@ namespace IceCreamShopDatabaseImplement.Implements
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
using var context = new IceCreamShopDataBase();
|
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)
|
public OrderViewModel? Insert(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
@ -62,7 +62,7 @@ namespace IceCreamShopDatabaseImplement.Implements
|
|||||||
public OrderViewModel? Update(OrderBindingModel model)
|
public OrderViewModel? Update(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
using var context = new IceCreamShopDataBase();
|
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);
|
model.Id);
|
||||||
if (order == null)
|
if (order == null)
|
||||||
{
|
{
|
||||||
|
@ -17,7 +17,7 @@ namespace IceCreamShopDatabaseImplement.Migrations
|
|||||||
{
|
{
|
||||||
#pragma warning disable 612, 618
|
#pragma warning disable 612, 618
|
||||||
modelBuilder
|
modelBuilder
|
||||||
.HasAnnotation("ProductVersion", "7.0.3")
|
.HasAnnotation("Version", "7.0.3")
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||||
|
|
||||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||||
|
@ -45,8 +45,9 @@ namespace IceCreamShopDatabaseImplement.Models
|
|||||||
DateImplement = model.DateImplement,
|
DateImplement = model.DateImplement,
|
||||||
IceCreamId = model.IceCreamId,
|
IceCreamId = model.IceCreamId,
|
||||||
IceCream = context.IceCreams.FirstOrDefault(x => x.Id == 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)
|
public void Update(OrderBindingModel? model)
|
||||||
|
@ -40,15 +40,12 @@ namespace IceCreamShopFileImplement.Implements
|
|||||||
}
|
}
|
||||||
public ClientViewModel? GetElement(ClientSearchModel model)
|
public ClientViewModel? GetElement(ClientSearchModel model)
|
||||||
{
|
{
|
||||||
if (!model.Id.HasValue && string.IsNullOrEmpty(model.ClientFIO))
|
return source.Clients
|
||||||
{
|
.FirstOrDefault(x => (string.IsNullOrEmpty(model.ClientFIO) || x.ClientFIO == model.ClientFIO) &&
|
||||||
return null;
|
(!model.Id.HasValue || x.Id == model.Id) && (string.IsNullOrEmpty(model.Email) || x.Email == model.Email) &&
|
||||||
}
|
(string.IsNullOrEmpty(model.Password) || x.Password == model.Password))
|
||||||
return source.Clients
|
?.GetViewModel;
|
||||||
.FirstOrDefault(x => (string.IsNullOrEmpty(model.ClientFIO) || x.ClientFIO == model.ClientFIO) &&
|
}
|
||||||
(!model.Id.HasValue || x.Id == model.Id))
|
|
||||||
?.GetViewModel;
|
|
||||||
}
|
|
||||||
public ClientViewModel? Insert(ClientBindingModel model)
|
public ClientViewModel? Insert(ClientBindingModel model)
|
||||||
{
|
{
|
||||||
model.Id = source.Clients.Count > 0 ? source.Clients.Max(x =>
|
model.Id = source.Clients.Count > 0 ? source.Clients.Max(x =>
|
||||||
|
@ -46,15 +46,11 @@ namespace IceCreamShopListImplement.Implements
|
|||||||
}
|
}
|
||||||
public ClientViewModel? GetElement(ClientSearchModel model)
|
public ClientViewModel? GetElement(ClientSearchModel model)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(model.ClientFIO) && !model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
foreach (var client in _source.Clients)
|
foreach (var client in _source.Clients)
|
||||||
{
|
{
|
||||||
if ((!string.IsNullOrEmpty(model.ClientFIO) &&
|
if ((string.IsNullOrEmpty(model.ClientFIO) || client.ClientFIO == model.ClientFIO) &&
|
||||||
client.ClientFIO == model.ClientFIO) ||
|
(!model.Id.HasValue || client.Id == model.Id) && (string.IsNullOrEmpty(model.Email) || client.Email == model.Email) &&
|
||||||
(model.Id.HasValue && client.Id == model.Id))
|
(string.IsNullOrEmpty(model.Password) || client.Password == model.Password))
|
||||||
{
|
{
|
||||||
return client.GetViewModel;
|
return client.GetViewModel;
|
||||||
}
|
}
|
||||||
|
@ -122,6 +122,8 @@ namespace IceCreamShopListImplement.Implements
|
|||||||
model.ClientFIO = client.ClientFIO;
|
model.ClientFIO = client.ClientFIO;
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,9 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<EmbeddedResource Include="log4net.config" />
|
<None Include="log4net.config">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@ -22,6 +24,8 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\IceCreamShopBusinessLogic\IceCreamShopBusinessLogic.csproj" />
|
<ProjectReference Include="..\IceCreamShopBusinessLogic\IceCreamShopBusinessLogic.csproj" />
|
||||||
<ProjectReference Include="..\IceCreamShopDatabaseImplement\IceCreamShopDatabaseImplement.csproj" />
|
<ProjectReference Include="..\IceCreamShopDatabaseImplement\IceCreamShopDatabaseImplement.csproj" />
|
||||||
|
<ProjectReference Include="..\IceCreamShopFileImplement\IceCreamShopFileImplement.csproj" />
|
||||||
|
<ProjectReference Include="..\IceCreamShopListImplement\IceCreamShopListImplement.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
Loading…
Reference in New Issue
Block a user