diff --git a/Canteen/CanteenBusinessLogic/BusinessLogics/LunchLogic.cs b/Canteen/CanteenBusinessLogic/BusinessLogics/LunchLogic.cs index f68b5bf..650006a 100644 --- a/Canteen/CanteenBusinessLogic/BusinessLogics/LunchLogic.cs +++ b/Canteen/CanteenBusinessLogic/BusinessLogics/LunchLogic.cs @@ -163,7 +163,9 @@ namespace CanteenBusinessLogic.BusinessLogics LunchName = _lunch.LunchName, Sum = _lunch.Sum, VisitorId = _lunch.VisitorId, - LunchOrders = _lunch.LunchOrders + DateImplement = _lunch.DateImplement, + LunchOrders = _lunch.LunchOrders, + Status = _lunch.Status, }) == null) { diff --git a/Canteen/CanteenBusinessLogic/BusinessLogics/OrderLogic.cs b/Canteen/CanteenBusinessLogic/BusinessLogics/OrderLogic.cs index c8365ac..c9b429c 100644 --- a/Canteen/CanteenBusinessLogic/BusinessLogics/OrderLogic.cs +++ b/Canteen/CanteenBusinessLogic/BusinessLogics/OrderLogic.cs @@ -109,7 +109,8 @@ namespace CanteenBusinessLogic.BusinessLogics Id = _order.Id, Description = _order.Description, VisitorId = _order.VisitorId, - OrderCooks = _order.OrderCooks + OrderCooks = _order.OrderCooks, + OrderTablewares = _order.OrderTablewares }) == null) { @@ -139,7 +140,8 @@ namespace CanteenBusinessLogic.BusinessLogics Id = _order.Id, Description = _order.Description, VisitorId = _order.VisitorId, - OrderTablewares = _order.OrderTablewares + OrderTablewares = _order.OrderTablewares, + OrderCooks = _order.OrderCooks }) == null) { diff --git a/Canteen/CanteenBusinessLogic/BusinessLogics/ReportLogic.cs b/Canteen/CanteenBusinessLogic/BusinessLogics/ReportLogic.cs index 0cf8bfe..7e9d0d3 100644 --- a/Canteen/CanteenBusinessLogic/BusinessLogics/ReportLogic.cs +++ b/Canteen/CanteenBusinessLogic/BusinessLogics/ReportLogic.cs @@ -93,8 +93,8 @@ namespace CanteenBusinessLogic.BusinessLogics var lunches = lunchStorage.GetFilteredList(new LunchSearchModel { - DateFrom = model.DateBefore, - DateTo = model.DateAfter, + DateFrom = model.DateAfter, + DateTo = model.DateBefore, }); foreach (var cook in cooks) @@ -119,7 +119,7 @@ namespace CanteenBusinessLogic.BusinessLogics } } - list.Add(record); + if (record.Lunches.Count > 0) list.Add(record); } return list; diff --git a/Canteen/CanteenDatabaseImplement/Implements/CookStorage.cs b/Canteen/CanteenDatabaseImplement/Implements/CookStorage.cs index dadd23d..39e3bb6 100644 --- a/Canteen/CanteenDatabaseImplement/Implements/CookStorage.cs +++ b/Canteen/CanteenDatabaseImplement/Implements/CookStorage.cs @@ -34,7 +34,7 @@ namespace CanteenDatabaseImplement.Implements public List GetFilteredList(CookSearchModel model) { - if (!model.Id.HasValue && !model.OrderId.HasValue && !model.ManagerId.HasValue) + if (!model.OrderId.HasValue && !model.ManagerId.HasValue) { return new(); } @@ -47,7 +47,6 @@ namespace CanteenDatabaseImplement.Implements .Include(x => x.Orders) .ThenInclude(x => x.Order) .Where(x => - (model.Id.HasValue && x.Id == model.Id) || (model.ManagerId.HasValue && model.ManagerId == x.ManagerId) || (model.OrderId.HasValue && x.Orders.Find(x => x.CookId == model.OrderId) != null)) .Select(x => x.GetViewModel) diff --git a/Canteen/CanteenDatabaseImplement/Implements/OrderStorage.cs b/Canteen/CanteenDatabaseImplement/Implements/OrderStorage.cs index d51488e..4d9941f 100644 --- a/Canteen/CanteenDatabaseImplement/Implements/OrderStorage.cs +++ b/Canteen/CanteenDatabaseImplement/Implements/OrderStorage.cs @@ -63,7 +63,6 @@ namespace CanteenDatabaseImplement.Implements .Include(x => x.Tablewares) .ThenInclude(x => x.Tableware) .Where(x => - (model.Id.HasValue && x.Id == model.Id) || (model.VisitorId.HasValue && model.VisitorId == x.VisitorId)) .Select(x => x.GetViewModel).ToList(); } diff --git a/Canteen/CanteenDatabaseImplement/Implements/ProductStorage.cs b/Canteen/CanteenDatabaseImplement/Implements/ProductStorage.cs index ab9e013..14d9984 100644 --- a/Canteen/CanteenDatabaseImplement/Implements/ProductStorage.cs +++ b/Canteen/CanteenDatabaseImplement/Implements/ProductStorage.cs @@ -55,8 +55,7 @@ namespace CanteenDatabaseImplement.Implements return context.Products .Include(x => x.Cooks) .ThenInclude(x => x.Cook) - .Where(x => (model.Id.HasValue && x.Id == model.Id) || - (model.ManagerId.HasValue && model.ManagerId == x.ManagerId)) + .Where(x => (model.ManagerId.HasValue && model.ManagerId == x.ManagerId)) .Select(x => x.GetViewModel).ToList(); } diff --git a/Canteen/CanteenDatabaseImplement/Implements/TablewareStorage.cs b/Canteen/CanteenDatabaseImplement/Implements/TablewareStorage.cs index 57af0a3..2464859 100644 --- a/Canteen/CanteenDatabaseImplement/Implements/TablewareStorage.cs +++ b/Canteen/CanteenDatabaseImplement/Implements/TablewareStorage.cs @@ -34,7 +34,7 @@ namespace CanteenDatabaseImplement.Implements using var context = new CanteenDatabase(); return context.Tablewares - .Where(x => (model.Id.HasValue && x.Id == model.Id) || (model.VisitorId.HasValue && model.VisitorId == x.VisitorId)) + .Where(x => (model.VisitorId.HasValue && model.VisitorId == x.VisitorId)) .Select(x => x.GetViewModel).ToList(); } diff --git a/Canteen/CanteenManagerApp/Views/Home/Report.cshtml b/Canteen/CanteenManagerApp/Views/Home/Report.cshtml index 0cc91a2..b12edfb 100644 --- a/Canteen/CanteenManagerApp/Views/Home/Report.cshtml +++ b/Canteen/CanteenManagerApp/Views/Home/Report.cshtml @@ -13,15 +13,15 @@

Pdf

- @Html.LabelFor(m => m.DateBefore, "От") - @Html.TextBoxFor(m => m.DateBefore, new { type = "date", @class = "form-control" }) + @Html.LabelFor(m => m.DateAfter, "От") + @Html.TextBoxFor(m => m.DateAfter, new { type = "date", @class = "form-control" })
- @Html.LabelFor(m => m.DateAfter, "До") - @Html.TextBoxFor(m => m.DateAfter, new { type = "date", @class = "form-control" }) + @Html.LabelFor(m => m.DateBefore, "До") + @Html.TextBoxFor(m => m.DateBefore, new { type = "date", @class = "form-control" })
diff --git a/Canteen/CanteenRestApi/Controllers/MainController.cs b/Canteen/CanteenRestApi/Controllers/MainController.cs index fad95dc..211b43c 100644 --- a/Canteen/CanteenRestApi/Controllers/MainController.cs +++ b/Canteen/CanteenRestApi/Controllers/MainController.cs @@ -558,7 +558,16 @@ namespace CanteenRestApi.Controllers { try { - _lunch.Update(model); + var lunch = _lunch.ReadElement(new LunchSearchModel { Id = model.Id }); + _lunch.Update(new LunchBindingModel + { + Id = lunch.Id, + LunchName = lunch.LunchName, + Sum = lunch.Sum, + DateImplement = lunch.DateImplement, + DateCreate = lunch.DateCreate, + VisitorId = lunch.VisitorId, + }); } catch (Exception ex) { @@ -597,7 +606,13 @@ namespace CanteenRestApi.Controllers { try { - _lunch.Finish(model); + var lunch = _lunch.ReadElement(new LunchSearchModel { Id = model.Id }); + _lunch.Finish(new LunchBindingModel + { + Id = lunch.Id, + LunchName = lunch.LunchName, + Sum = lunch.Sum + }); } catch (Exception ex) { diff --git a/Canteen/CanteenVisitorApp/Controllers/HomeController.cs b/Canteen/CanteenVisitorApp/Controllers/HomeController.cs index d3d4ddf..9c07c26 100644 --- a/Canteen/CanteenVisitorApp/Controllers/HomeController.cs +++ b/Canteen/CanteenVisitorApp/Controllers/HomeController.cs @@ -442,7 +442,7 @@ namespace CanteenVisitorApp.Controllers { Id = id, VisitorId = APIClient.Visitor.Id, - LunchName = name + LunchName = name, }); Response.Redirect("Lunches"); } @@ -493,8 +493,15 @@ namespace CanteenVisitorApp.Controllers { return Redirect("~/Home/Enter"); } - ViewBag.LunchList = APIClient.GetRequest>($"api/main/getlunchlist?visitorId={APIClient.Visitor.Id}"); - ViewBag.OrderList = APIClient.GetRequest>($"api/main/getorderlist?visitorId={APIClient.Visitor.Id}"); + // Получение данных и сохранение их в переменные + var lunchList = APIClient.GetRequest>($"api/main/getlunchlist?visitorId={APIClient.Visitor.Id}"); + var orderList = APIClient.GetRequest>($"api/main/getorderlist?visitorId={APIClient.Visitor.Id}"); + + // Сохранение данных в ViewBag + ViewBag.LunchList = lunchList; + ViewBag.OrderList = orderList; + + // Возвращение представления return View(); } [HttpPost] diff --git a/Canteen/CanteenVisitorApp/Views/Home/LunchAddOrders.cshtml b/Canteen/CanteenVisitorApp/Views/Home/LunchAddOrders.cshtml index 02eaaf5..374cfbb 100644 --- a/Canteen/CanteenVisitorApp/Views/Home/LunchAddOrders.cshtml +++ b/Canteen/CanteenVisitorApp/Views/Home/LunchAddOrders.cshtml @@ -15,7 +15,7 @@
Обед:
- @foreach (var order in ViewBag.OrderList as List) + @foreach (var order in ViewBag.OrderList) { } diff --git a/Canteen/CanteenVisitorApp/Views/Home/Report.cshtml b/Canteen/CanteenVisitorApp/Views/Home/Report.cshtml index eee8119..3bfc90b 100644 --- a/Canteen/CanteenVisitorApp/Views/Home/Report.cshtml +++ b/Canteen/CanteenVisitorApp/Views/Home/Report.cshtml @@ -13,15 +13,15 @@

Pdf

- @Html.LabelFor(m => m.DateBefore, "От") - @Html.TextBoxFor(m => m.DateBefore, new { type = "date", @class = "form-control" }) + @Html.LabelFor(m => m.DateAfter, "От") + @Html.TextBoxFor(m => m.DateAfter, new { type = "date", @class = "form-control" })
- @Html.LabelFor(m => m.DateAfter, "До") - @Html.TextBoxFor(m => m.DateAfter, new { type = "date", @class = "form-control" }) + @Html.LabelFor(m => m.DateBefore, "До") + @Html.TextBoxFor(m => m.DateBefore, new { type = "date", @class = "form-control" })