Merge branch 'WebRepart' of https://git.is.ulstu.ru/Ilfedotov.01/CourseWorkElectronicsShop into WebRepart
This commit is contained in:
commit
92be4d7331
@ -87,11 +87,12 @@ namespace ElectronicsShopDataBaseImplement.Models
|
|||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
}
|
}
|
||||||
var order = context.Orders.First(x => x.ID == model.ID);
|
var order = context.Orders.First(x => x.ID == model.ID);
|
||||||
|
order.Sum = model.Sum;
|
||||||
foreach (var op in model.ProductList) {
|
foreach (var op in model.ProductList) {
|
||||||
context.OrderProducts.Add(new OrderProduct {
|
context.OrderProducts.Add(new OrderProduct {
|
||||||
_order = order,
|
_order = order,
|
||||||
_product = context.Products.First(x => x.ID == op.Key),
|
_product = context.Products.First(x => x.ID == op.Key),
|
||||||
Count = op.Value.Item2
|
Count = op.Value.Item2,
|
||||||
});
|
});
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
}
|
}
|
||||||
|
@ -161,7 +161,7 @@ namespace ElectronicsShopRestAPI.Controllers {
|
|||||||
ClientID = view.ClientID,
|
ClientID = view.ClientID,
|
||||||
DateCreate = view.DateCreate,
|
DateCreate = view.DateCreate,
|
||||||
ProductList = _productlist,
|
ProductList = _productlist,
|
||||||
//sum
|
Sum = Calc(_productlist)
|
||||||
};
|
};
|
||||||
var operationResult = _order.Update(model);
|
var operationResult = _order.Update(model);
|
||||||
if (!operationResult) {
|
if (!operationResult) {
|
||||||
@ -198,8 +198,8 @@ namespace ElectronicsShopRestAPI.Controllers {
|
|||||||
ID = _orderId,
|
ID = _orderId,
|
||||||
ClientID = view.ClientID,
|
ClientID = view.ClientID,
|
||||||
DateCreate = view.DateCreate,
|
DateCreate = view.DateCreate,
|
||||||
ProductList = _productlist
|
ProductList = _productlist,
|
||||||
//sum
|
Sum = Calc(_productlist)
|
||||||
};
|
};
|
||||||
var operationResult = _order.DeleteProduct(model);
|
var operationResult = _order.DeleteProduct(model);
|
||||||
if (!operationResult) {
|
if (!operationResult) {
|
||||||
@ -211,5 +211,14 @@ namespace ElectronicsShopRestAPI.Controllers {
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public double Calc(Dictionary<int, (IProductModel, int)> _productlist) {
|
||||||
|
double ans = 0;
|
||||||
|
foreach (var item in _productlist) {
|
||||||
|
ans += item.Value.Item1.Price * item.Value.Item2;
|
||||||
|
}
|
||||||
|
return ans;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,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">
|
||||||
<input type="submit" value="Заказ готова, вернуться!" class="btn btn-primary" />
|
<input type="submit" value="Заказ готов, вернуться!" class="btn btn-primary" />
|
||||||
<a class="btn btn-primary btn-sm" asp-action="DeleteOrder" asp-route-ID="@Model.Item1">Удалить</a>
|
<a class="btn btn-primary btn-sm" asp-action="DeleteOrder" asp-route-ID="@Model.Item1">Удалить</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -76,7 +76,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">
|
||||||
<input type="submit" value="Заказ готова, вернуться!" class="btn btn-primary" />
|
<input type="submit" value="Заказ готов, вернуться!" class="btn btn-primary" />
|
||||||
<a class="btn btn-primary btn-sm" asp-action="DeleteOrder" asp-route-ID="@Model.Item1">Отменить создание корзины</a>
|
<a class="btn btn-primary btn-sm" asp-action="DeleteOrder" asp-route-ID="@Model.Item1">Отменить создание корзины</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
<header>
|
<header>
|
||||||
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
|
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">ElectronicsShopClientApp</a>
|
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">Магазин электроники (Клиент)</a>
|
||||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
|
||||||
aria-expanded="false" aria-label="Toggle navigation">
|
aria-expanded="false" aria-label="Toggle navigation">
|
||||||
<span class="navbar-toggler-icon"></span>
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
Loading…
Reference in New Issue
Block a user