diff --git a/Canteen/CanteenBusinessLogic/BusinessLogics/LunchLogic.cs b/Canteen/CanteenBusinessLogic/BusinessLogics/LunchLogic.cs index 22e8828..32a073c 100644 --- a/Canteen/CanteenBusinessLogic/BusinessLogics/LunchLogic.cs +++ b/Canteen/CanteenBusinessLogic/BusinessLogics/LunchLogic.cs @@ -153,67 +153,65 @@ namespace CanteenBusinessLogic.BusinessLogics return true; } - public bool AddOrder(LunchOrderBindingModel model) + public bool UpdateOrders(LunchBindingModel lunch, OrderBindingModel order) { - CheckModel(model, false); - _logger.LogInformation("AddOrder. LunchId: {LunchId}. OrderId: {OrderId}. CountOrder: {CountOrder}", model.OrderId, model.LunchId, model.OrderCount); - if (!_lunchStorage.AddOrder(model)) + var _lunch = _lunchStorage.GetElement(new LunchSearchModel { Id = lunch.Id}); + _lunch.LunchOrders[order.Id] = order as IOrderModel; + if (_lunchStorage.Update(new() { - _logger.LogWarning("AddOrder operation failed"); + Id = _lunch.Id, + LunchName = _lunch.LunchName, + Sum = _lunch.Sum, + VisitorId = _lunch.VisitorId, + LunchOrders = _lunch.LunchOrders + + }) == null) + { + _logger.LogWarning("Update operation failed"); return false; } return true; } - private void CheckModel(LunchOrderBindingModel model, bool withParams = true) + + public bool UpdateProducts(LunchBindingModel lunch, ProductBindingModel product, int count) { - if (model == null) + var _lunch = _lunchStorage.GetElement(new LunchSearchModel { Id = lunch.Id }); + if (count == -1) { - throw new ArgumentNullException(nameof(model)); + if (_lunch.LunchProducts.ContainsKey(product.Id)) + { + _lunch.LunchProducts.Remove(product.Id); + } + } + else if (count > 0) + { + _lunch.LunchProducts[product.Id] = (product, count); + } + double allSum = 0; + foreach (var lunchProducts in _lunch.LunchProducts) + { + IProductModel _product = lunchProducts.Value.Item1; + int _count = lunchProducts.Value.Item2; + allSum += _product.Price * _count; + } + if (_lunchStorage.Update(new() + { + Id = _lunch.Id, + LunchName = _lunch.LunchName, + VisitorId = _lunch.VisitorId, + LunchProducts = _lunch.LunchProducts, + DateCreate = _lunch.DateCreate, + Status = _lunch.Status, + DateImplement = _lunch.DateImplement, + Sum = allSum + }) == null) + { + _logger.LogWarning("Update operation failed"); + return false; } - if (!withParams) - { - return; - } - - if (model.OrderId <= 0) - { - throw new ArgumentNullException("id заказа должен быть больше 0", nameof(model.OrderId)); - } - - if (model.LunchId <= 0) - { - throw new ArgumentNullException("id обеда должен быть больше 0", nameof(model.LunchId)); - } - - if (model.VisitorId <= 0) - { - throw new ArgumentNullException("id посетителя должен быть больше 0", nameof(model.VisitorId)); - } - - if (model.OrderCount <= 0) - { - throw new ArgumentNullException("количество одного заказа должно быть больше 0", nameof(model.OrderCount)); - } - - _logger.LogInformation("LunchOrder. OrderId: {OrderId}. LunchId: {LunchId}. VisitorId: {VisitorId}. OrderCount: {OrderCount}", model.OrderId, model.LunchId, model.VisitorId, model.OrderCount); - - var element = _lunchStorage.GetLunchOrderElement(new LunchOrderSearchModel { Id = model.Id, OrderId = model.OrderId, LunchId = model.LunchId }); - if (element != null && element.Id != model.Id) - { - throw new InvalidOperationException("Такая связь уже есть"); - } - } - - public bool AddProductToLunch(LunchSearchModel model, IProductModel product, int count) - { - throw new NotImplementedException(); - } - - public bool AddOrderToLunch(LunchSearchModel model, IOrderModel order, int count) - { - throw new NotImplementedException(); + return true; } } } diff --git a/Canteen/CanteenBusinessLogic/BusinessLogics/OrderLogic.cs b/Canteen/CanteenBusinessLogic/BusinessLogics/OrderLogic.cs index 3b193a5..c8365ac 100644 --- a/Canteen/CanteenBusinessLogic/BusinessLogics/OrderLogic.cs +++ b/Canteen/CanteenBusinessLogic/BusinessLogics/OrderLogic.cs @@ -25,16 +25,6 @@ namespace CanteenBusinessLogic.BusinessLogics _orderStorage = orderStorage; } - public bool AddCooksToOrder(OrderSearchModel model, ICookModel cook) - { - throw new NotImplementedException(); - } - - public bool AddTablewareToOrder(OrderTablewareBindingModel model, ITablewareModel tableware, int count) - { - throw new NotImplementedException(); - } - public bool Create(OrderBindingModel model) { CheckModel(model); @@ -110,6 +100,56 @@ namespace CanteenBusinessLogic.BusinessLogics return true; } + public bool UpdateCooks(OrderBindingModel order, CookBindingModel cook) + { + var _order = _orderStorage.GetElement(new OrderSearchModel { Id = order.Id }); + _order.OrderCooks[cook.Id] = cook as ICookModel; + if (_orderStorage.Update(new() + { + Id = _order.Id, + Description = _order.Description, + VisitorId = _order.VisitorId, + OrderCooks = _order.OrderCooks + + }) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + + return true; + } + + public bool UpdateTablewares(OrderBindingModel order, TablewareBindingModel tableware, int count) + { + var _order = _orderStorage.GetElement(new OrderSearchModel { Id = order.Id }); + if (count == -1) + { + if (_order.OrderTablewares.ContainsKey(tableware.Id)) + { + _order.OrderTablewares.Remove(tableware.Id); + } + } + else if (count > 0) + { + _order.OrderTablewares[tableware.Id] = (tableware, count); + } + if (_orderStorage.Update(new() + { + Id = _order.Id, + Description = _order.Description, + VisitorId = _order.VisitorId, + OrderTablewares = _order.OrderTablewares + + }) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + + return true; + } + private void CheckModel(OrderBindingModel model, bool withParams = true) { if (model == null) @@ -132,12 +172,7 @@ namespace CanteenBusinessLogic.BusinessLogics throw new ArgumentNullException("id посетителя должен быть больше 0", nameof(model.VisitorId)); } - if (model.Sum <= 0) - { - throw new ArgumentNullException("Сумма заказа должна быть больше 0", nameof(model.Sum)); - } - - _logger.LogInformation("Order. Description: {Description}. Sum: {Sum}. VisitorId: {VisitorId}. Id: {Id}", model.Description, model.Sum, model.VisitorId, model.Id); + _logger.LogInformation("Order. Description: {Description}. VisitorId: {VisitorId}. Id: {Id}", model.Description, model.VisitorId, model.Id); var element = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id }); if (element != null && element.Id != model.Id) @@ -145,80 +180,5 @@ namespace CanteenBusinessLogic.BusinessLogics throw new InvalidOperationException("Заказ с таким id уже есть"); } } - private void CheckModel(OrderCookBindingModel model, bool withParams = true) - { - if (model == null) - { - throw new ArgumentNullException(nameof(model)); - } - - if (!withParams) - { - return; - } - - if (model.OrderId <= 0) - { - throw new ArgumentNullException("id заказа должен быть больше 0", nameof(model.OrderId)); - } - - if (model.CookId <= 0) - { - throw new ArgumentNullException("id повара должен быть больше 0", nameof(model.CookId)); - } - - if (model.VisitorId <= 0) - { - throw new ArgumentNullException("id посетителя должен быть больше 0", nameof(model.VisitorId)); - } - - _logger.LogInformation("OrderCook. OrderId: {OrderId}. CookId: {CookId}. VisitorId: {VisitorId}", model.OrderId, model.CookId, model.VisitorId); - - var element = _orderStorage.GetOrderCookElement(new OrderCookSearchModel { Id = model.Id, OrderId = model.OrderId, CookId = model.CookId }); - if (element != null && element.Id != model.Id) - { - throw new InvalidOperationException("Такая связь уже есть"); - } - } - private void CheckModel(OrderTablewareBindingModel model, bool withParams = true) - { - if (model == null) - { - throw new ArgumentNullException(nameof(model)); - } - - if (!withParams) - { - return; - } - - if (model.OrderId <= 0) - { - throw new ArgumentNullException("id заказа должен быть больше 0", nameof(model.OrderId)); - } - - if (model.TablewareId <= 0) - { - throw new ArgumentNullException("id прибора должен быть больше 0", nameof(model.TablewareId)); - } - - if (model.VisitorId <= 0) - { - throw new ArgumentNullException("id посетителя должен быть больше 0", nameof(model.VisitorId)); - } - - if (model.CountTablewares <= 0) - { - throw new ArgumentNullException("количество одного прибора должено быть больше 0", nameof(model.CountTablewares)); - } - - _logger.LogInformation("OrderTableware. OrderId: {OrderId}. TablewareId: {TablewareId}. VisitorId: {VisitorId}. CountTablewares: {CountTablewares}", model.OrderId, model.TablewareId, model.VisitorId, model.CountTablewares); - - var element = _orderStorage.GetElement(new OrderSearchModel { Id = model.OrderId}); - //if (element != null && element.Id == model.OrderId && element.TablewareId == model.TablewareId) - //{ - // throw new InvalidOperationException("Такая связь уже есть"); - //} - } } } diff --git a/Canteen/CanteenContracts/BindingModels/LunchBindingModel.cs b/Canteen/CanteenContracts/BindingModels/LunchBindingModel.cs index 718893c..afa6c94 100644 --- a/Canteen/CanteenContracts/BindingModels/LunchBindingModel.cs +++ b/Canteen/CanteenContracts/BindingModels/LunchBindingModel.cs @@ -18,6 +18,6 @@ namespace CanteenContracts.BindingModels public DateTime DateCreate { get; set; } = DateTime.Now; public DateTime? DateImplement { get; set; } public Dictionary LunchProducts { get; set; } = new Dictionary(); - public Dictionary LunchOrders { get; set; } = new Dictionary(); + public Dictionary LunchOrders { get; set; } = new Dictionary(); } } diff --git a/Canteen/CanteenContracts/BindingModels/OrderBindingModel.cs b/Canteen/CanteenContracts/BindingModels/OrderBindingModel.cs index 4fba46e..e3ba33e 100644 --- a/Canteen/CanteenContracts/BindingModels/OrderBindingModel.cs +++ b/Canteen/CanteenContracts/BindingModels/OrderBindingModel.cs @@ -13,8 +13,6 @@ namespace CanteenContracts.BindingModels public int Id { get; set; } public int VisitorId { get; set; } public string Description { get; set; } = string.Empty; - public double? Sum { get; set; } - public int? TablewareId { get; set; } public int? CountTablewares { get; set; } public Dictionary OrderCooks { get; set; } = new (); public Dictionary OrderTablewares { get; set; } = new (); diff --git a/Canteen/CanteenContracts/BusinessLogicsContracts/ILunchLogic.cs b/Canteen/CanteenContracts/BusinessLogicsContracts/ILunchLogic.cs index 63374e2..a02f158 100644 --- a/Canteen/CanteenContracts/BusinessLogicsContracts/ILunchLogic.cs +++ b/Canteen/CanteenContracts/BusinessLogicsContracts/ILunchLogic.cs @@ -18,7 +18,7 @@ namespace CanteenContracts.BusinessLogicsContracts bool Update(LunchBindingModel model); bool Delete(LunchBindingModel model); bool Finish(LunchBindingModel model); - bool AddProductToLunch(LunchSearchModel model, IProductModel product, int count); - bool AddOrderToLunch(LunchSearchModel model, IOrderModel order, int count); + bool UpdateOrders(LunchBindingModel lunch, OrderBindingModel order); + bool UpdateProducts(LunchBindingModel lunch, ProductBindingModel product, int count); } } diff --git a/Canteen/CanteenContracts/BusinessLogicsContracts/IOrderLogic.cs b/Canteen/CanteenContracts/BusinessLogicsContracts/IOrderLogic.cs index f30a37d..f77ceea 100644 --- a/Canteen/CanteenContracts/BusinessLogicsContracts/IOrderLogic.cs +++ b/Canteen/CanteenContracts/BusinessLogicsContracts/IOrderLogic.cs @@ -17,7 +17,7 @@ namespace CanteenContracts.BusinessLogicsContracts bool Create(OrderBindingModel model); bool Delete(OrderBindingModel model); bool Update(OrderBindingModel model); - bool AddTablewareToOrder(OrderTablewareBindingModel model, ITablewareModel tableware, int count); - bool AddCooksToOrder(OrderSearchModel model, ICookModel cook); + bool UpdateTablewares(OrderBindingModel order, TablewareBindingModel tableware, int count); + bool UpdateCooks(OrderBindingModel order, CookBindingModel cooks); } } diff --git a/Canteen/CanteenContracts/StoragesContracts/ILunchStorage.cs b/Canteen/CanteenContracts/StoragesContracts/ILunchStorage.cs index 5859591..beb266c 100644 --- a/Canteen/CanteenContracts/StoragesContracts/ILunchStorage.cs +++ b/Canteen/CanteenContracts/StoragesContracts/ILunchStorage.cs @@ -20,6 +20,5 @@ namespace CanteenContracts.StoragesContracts LunchViewModel? Insert(LunchBindingModel model); LunchViewModel? Update(LunchBindingModel model); LunchViewModel? Delete(LunchBindingModel model); - bool AddOrder(LunchOrderBindingModel model); } } diff --git a/Canteen/CanteenContracts/ViewModels/LunchViewModel.cs b/Canteen/CanteenContracts/ViewModels/LunchViewModel.cs index 0c1fb26..73e457d 100644 --- a/Canteen/CanteenContracts/ViewModels/LunchViewModel.cs +++ b/Canteen/CanteenContracts/ViewModels/LunchViewModel.cs @@ -24,6 +24,7 @@ namespace CanteenContracts.View public DateTime DateCreate { get; set; } [DisplayName("Дата реализации")] public DateTime? DateImplement { get; set; } - public Dictionary LunchProducts { get; set; } = new(); + public Dictionary LunchProducts { get; set; } + public Dictionary LunchOrders { get; set; } } } diff --git a/Canteen/CanteenContracts/ViewModels/OrderViewModel.cs b/Canteen/CanteenContracts/ViewModels/OrderViewModel.cs index c6c1eb9..e27845d 100644 --- a/Canteen/CanteenContracts/ViewModels/OrderViewModel.cs +++ b/Canteen/CanteenContracts/ViewModels/OrderViewModel.cs @@ -6,6 +6,7 @@ using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; +using Newtonsoft.Json; namespace CanteenContracts.View { @@ -15,12 +16,15 @@ namespace CanteenContracts.View public int VisitorId { get; set; } [DisplayName("Описание")] public string Description { get; set; } = string.Empty; - [DisplayName("Сумма")] - public double? Sum { get; set; } - public Dictionary OrderCooks { get; set; } = new Dictionary(); - public Dictionary OrderTablewares { get; set; } = new Dictionary(); + public Dictionary OrderCooks { get; set; } + public Dictionary OrderTablewares { get; set; } [DisplayName("ID заказа")] public int Id { get; set; } + public OrderViewModel() { } + [JsonConstructor] + public OrderViewModel(Dictionary OrderCooks) + { + this.OrderCooks = OrderCooks.ToDictionary(x => x.Key, x => x.Value as ICookModel); + } } - } diff --git a/Canteen/CanteenContracts/ViewModels/ProductViewModel.cs b/Canteen/CanteenContracts/ViewModels/ProductViewModel.cs index 0b90941..a5224c4 100644 --- a/Canteen/CanteenContracts/ViewModels/ProductViewModel.cs +++ b/Canteen/CanteenContracts/ViewModels/ProductViewModel.cs @@ -21,7 +21,7 @@ namespace CanteenContracts.View [DisplayName("ID менеджера")] public int ManagerId { get; set; } - public Dictionary ProductCooks { get; set; } = new(); + public Dictionary ProductCooks { get; set; } public ProductViewModel() { } [JsonConstructor] diff --git a/Canteen/CanteenDataModels/Models/IOrderModel.cs b/Canteen/CanteenDataModels/Models/IOrderModel.cs index a1eef5d..6caa26c 100644 --- a/Canteen/CanteenDataModels/Models/IOrderModel.cs +++ b/Canteen/CanteenDataModels/Models/IOrderModel.cs @@ -11,7 +11,6 @@ namespace CanteenDataModels.Models { int VisitorId { get; } string Description { get; } - double? Sum { get; } Dictionary OrderCooks { get; } Dictionary OrderTablewares { get; } } diff --git a/Canteen/CanteenDatabaseImplement/CanteenDatabase.cs b/Canteen/CanteenDatabaseImplement/CanteenDatabase.cs index c87f044..a924378 100644 --- a/Canteen/CanteenDatabaseImplement/CanteenDatabase.cs +++ b/Canteen/CanteenDatabaseImplement/CanteenDatabase.cs @@ -21,83 +21,98 @@ namespace CanteenDatabaseImplement .HasOne(dp => dp.Dish) .WithMany(d => d.Products) .HasForeignKey(dp => dp.DishId) - .OnDelete(DeleteBehavior.NoAction); + .OnDelete(DeleteBehavior.Restrict); modelBuilder.Entity() .HasOne(dp => dp.Product) .WithMany(p => p.Dishes) .HasForeignKey(dp => dp.ProductId) - .OnDelete(DeleteBehavior.NoAction); + .OnDelete(DeleteBehavior.Restrict); //===================================== modelBuilder.Entity() .HasOne(dp => dp.Lunch) .WithMany(d => d.Orders) .HasForeignKey(dp => dp.LunchId) - .OnDelete(DeleteBehavior.NoAction); + .OnDelete(DeleteBehavior.Restrict); modelBuilder.Entity() .HasOne(dp => dp.Order) .WithMany(p => p.Lunches) .HasForeignKey(dp => dp.OrderId) - .OnDelete(DeleteBehavior.NoAction); + .OnDelete(DeleteBehavior.Restrict); //===================================== modelBuilder.Entity() .HasOne(dp => dp.Lunch) .WithMany(d => d.Products) .HasForeignKey(dp => dp.LunchId) - .OnDelete(DeleteBehavior.NoAction); + .OnDelete(DeleteBehavior.Restrict); modelBuilder.Entity() .HasOne(dp => dp.Product) .WithMany(p => p.Lunches) .HasForeignKey(dp => dp.ProductId) - .OnDelete(DeleteBehavior.NoAction); + .OnDelete(DeleteBehavior.Restrict); //===================================== modelBuilder.Entity() .HasOne(dp => dp.Order) .WithMany(d => d.Cooks) .HasForeignKey(dp => dp.OrderId) - .OnDelete(DeleteBehavior.NoAction); + .OnDelete(DeleteBehavior.Restrict); modelBuilder.Entity() .HasOne(dp => dp.Cook) .WithMany(p => p.Orders) .HasForeignKey(dp => dp.CookId) - .OnDelete(DeleteBehavior.NoAction); + .OnDelete(DeleteBehavior.Restrict); //===================================== modelBuilder.Entity() .HasOne(dp => dp.Order) .WithMany(d => d.Tablewares) .HasForeignKey(dp => dp.OrderId) - .OnDelete(DeleteBehavior.NoAction); + .OnDelete(DeleteBehavior.Restrict); modelBuilder.Entity() .HasOne(dp => dp.Tableware) .WithMany(p => p.Orders) .HasForeignKey(dp => dp.TablewareId) - .OnDelete(DeleteBehavior.NoAction); + .OnDelete(DeleteBehavior.Restrict); //===================================== modelBuilder.Entity() .HasOne(dp => dp.Product) .WithMany(d => d.Cooks) .HasForeignKey(dp => dp.ProductId) - .OnDelete(DeleteBehavior.NoAction); + .OnDelete(DeleteBehavior.Restrict); modelBuilder.Entity() .HasOne(dp => dp.Cook) .WithMany(p => p.Products) .HasForeignKey(dp => dp.CookId) - .OnDelete(DeleteBehavior.NoAction); + .OnDelete(DeleteBehavior.Restrict); //===================================== modelBuilder.Entity() .HasOne(b => b.Visitor) .WithMany(a => a.Orders) - .OnDelete(DeleteBehavior.NoAction); + .OnDelete(DeleteBehavior.Cascade); + //===================================== + modelBuilder.Entity() + .HasOne(b => b.Visitor) + .WithMany(a => a.Lunches) + .OnDelete(DeleteBehavior.Cascade); + //===================================== + modelBuilder.Entity() + .HasOne(b => b.Visitor) + .WithMany(a => a.Orders) + .OnDelete(DeleteBehavior.Cascade); + //===================================== + modelBuilder.Entity() + .HasOne(b => b.Visitor) + .WithMany(a => a.Orders) + .OnDelete(DeleteBehavior.Cascade); //===================================== } diff --git a/Canteen/CanteenDatabaseImplement/Implements/DishStorage.cs b/Canteen/CanteenDatabaseImplement/Implements/DishStorage.cs index 394c755..4fbc2f5 100644 --- a/Canteen/CanteenDatabaseImplement/Implements/DishStorage.cs +++ b/Canteen/CanteenDatabaseImplement/Implements/DishStorage.cs @@ -42,13 +42,18 @@ namespace CanteenDatabaseImplement.Implements return context.Dishes .Include(x => x.Products) .ThenInclude(x => x.Product) - .Where(x => x.DishName == model.DishName || (model.ManagerId.HasValue && model.ManagerId == x.ManagerId)).Select(x => x.GetViewModel).ToList(); + .Where(x => x.DishName == model.DishName || (model.ManagerId.HasValue && model.ManagerId == x.ManagerId)) + .Select(x => x.GetViewModel).ToList(); } public List GetFullList() { using var context = new CanteenDatabase(); - return context.Dishes.Include(x => x.Products).ThenInclude(x => x.Product).Select(x => x.GetViewModel).ToList(); + return context.Dishes + .Include(x => x.Products) + .ThenInclude(x => x.Product) + .Select(x => x.GetViewModel) + .ToList(); } public DishViewModel? Insert(DishBindingModel model) @@ -99,7 +104,7 @@ namespace CanteenDatabaseImplement.Implements dish.Update(model); context.SaveChanges(); - dish.UpdateDishProduct(context, model); + if (model.DishProducts.Any()) dish.UpdateDishProduct(context, model); context.Database.CommitTransaction(); return dish.GetViewModel; diff --git a/Canteen/CanteenDatabaseImplement/Implements/LunchStorage.cs b/Canteen/CanteenDatabaseImplement/Implements/LunchStorage.cs index 5c9e277..0c055f7 100644 --- a/Canteen/CanteenDatabaseImplement/Implements/LunchStorage.cs +++ b/Canteen/CanteenDatabaseImplement/Implements/LunchStorage.cs @@ -28,6 +28,8 @@ namespace CanteenDatabaseImplement.Implements return context.Lunches .Include(x => x.Products) .ThenInclude(x => x.Product) + .Include(x => x.Orders) + .ThenInclude(x => x.Order) .FirstOrDefault(x => (x.DateCreate >= model.DateFrom && x.DateImplement <= model.DateTo) || (x.Id == model.Id))?.GetViewModel; } public LunchOrderViewModel? GetLunchOrderElement(LunchOrderSearchModel model) @@ -44,7 +46,7 @@ namespace CanteenDatabaseImplement.Implements } public List GetFilteredList(LunchSearchModel model) { - if (!model.DateFrom.HasValue || !model.DateTo.HasValue) + if (!model.VisitorId.HasValue) { return new(); } @@ -54,6 +56,8 @@ namespace CanteenDatabaseImplement.Implements return context.Lunches .Include(x => x.Products) .ThenInclude(x => x.Product) + .Include(x => x.Orders) + .ThenInclude(x => x.Order) .Where(x => (x.DateCreate >= model.DateFrom && x.DateImplement <= model.DateTo) || (model.Id.HasValue && x.Id == model.Id) || @@ -66,6 +70,8 @@ namespace CanteenDatabaseImplement.Implements return context.Lunches .Include(x => x.Products) .ThenInclude(x => x.Product) + .Include(x => x.Orders) + .ThenInclude(x => x.Order) .Select(x => x.GetViewModel).ToList(); } public LunchViewModel? Insert(LunchBindingModel model) @@ -115,10 +121,8 @@ namespace CanteenDatabaseImplement.Implements lunch.Update(model); context.SaveChanges(); - if (model.LunchProducts != null) - lunch.UpdateProducts(context, model); - if (model.LunchOrders != null) - lunch.UpdateOrders(context, model); + if (model.LunchProducts.Any()) lunch.UpdateProducts(context, model); + if (model.LunchOrders.Any()) lunch.UpdateOrders(context, model); context.Database.CommitTransaction(); return lunch.GetViewModel; @@ -145,30 +149,5 @@ namespace CanteenDatabaseImplement.Implements return null; } - public bool AddOrder(LunchOrderBindingModel lunchOrder) - { - using var context = new CanteenDatabase(); - using var transaction = context.Database.BeginTransaction(); - try - { - var _lunchOrder = context.LunchOrder.FirstOrDefault(rec => rec.LunchId == lunchOrder.LunchId && rec.OrderId == lunchOrder.OrderId); - if (_lunchOrder != null) - { - _lunchOrder.CountOrders = lunchOrder.OrderCount; - } - else - { - context.LunchOrder.Add(new LunchOrder { LunchId = lunchOrder.LunchId, OrderId = lunchOrder.OrderId, CountOrders = lunchOrder.OrderCount }); - } - context.SaveChanges(); - transaction.Commit(); - return true; - } - catch - { - transaction.Rollback(); - return false; - } - } } } diff --git a/Canteen/CanteenDatabaseImplement/Implements/OrderStorage.cs b/Canteen/CanteenDatabaseImplement/Implements/OrderStorage.cs index ce71536..8a186f2 100644 --- a/Canteen/CanteenDatabaseImplement/Implements/OrderStorage.cs +++ b/Canteen/CanteenDatabaseImplement/Implements/OrderStorage.cs @@ -40,8 +40,11 @@ namespace CanteenDatabaseImplement.Implements return context.Orders .Include(x => x.Cooks) - .ThenInclude(x => x.Cook) - .FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)?.GetViewModel; + .ThenInclude(x => x.Cook) + .Include(x => x.Tablewares) + .ThenInclude(x => x.Tableware) + .FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)? + .GetViewModel; } public List GetFilteredList(OrderSearchModel model) @@ -56,6 +59,8 @@ namespace CanteenDatabaseImplement.Implements return context.Orders .Include(x => x.Cooks) .ThenInclude(x => x.Cook) + .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(); } @@ -88,16 +93,18 @@ namespace CanteenDatabaseImplement.Implements { using var context = new CanteenDatabase(); - var client = context.Orders.FirstOrDefault(x => x.Id == model.Id); - if (client == null) + var order = context.Orders.FirstOrDefault(x => x.Id == model.Id); + if (order == null) { return null; } - client.Update(model); + order.Update(model); context.SaveChanges(); + if (model.OrderTablewares.Any()) order.UpdateOrderTablewares(context, model); + if (model.OrderCooks.Any()) order.UpdateOrderCook(context, model); - return client.GetViewModel; + return order.GetViewModel; } public OrderViewModel? Delete(OrderBindingModel model) diff --git a/Canteen/CanteenDatabaseImplement/Implements/ProductStorage.cs b/Canteen/CanteenDatabaseImplement/Implements/ProductStorage.cs index 2ef9078..1d818be 100644 --- a/Canteen/CanteenDatabaseImplement/Implements/ProductStorage.cs +++ b/Canteen/CanteenDatabaseImplement/Implements/ProductStorage.cs @@ -113,7 +113,7 @@ namespace CanteenDatabaseImplement.Implements product.Update(model); context.SaveChanges(); - if (model.ProductCooks != null) + if (model.ProductCooks.Any()) product.UpdateProductCooks(context, model); context.Database.CommitTransaction(); diff --git a/Canteen/CanteenDatabaseImplement/Migrations/20230518211530_Init.Designer.cs b/Canteen/CanteenDatabaseImplement/Migrations/20230519185610_Init.Designer.cs similarity index 95% rename from Canteen/CanteenDatabaseImplement/Migrations/20230518211530_Init.Designer.cs rename to Canteen/CanteenDatabaseImplement/Migrations/20230519185610_Init.Designer.cs index 7e8305e..a4fbebc 100644 --- a/Canteen/CanteenDatabaseImplement/Migrations/20230518211530_Init.Designer.cs +++ b/Canteen/CanteenDatabaseImplement/Migrations/20230519185610_Init.Designer.cs @@ -12,7 +12,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace CanteenDatabaseImplement.Migrations { [DbContext(typeof(CanteenDatabase))] - [Migration("20230518211530_Init")] + [Migration("20230519185610_Init")] partial class Init { /// @@ -144,9 +144,6 @@ namespace CanteenDatabaseImplement.Migrations SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - b.Property("CountOrders") - .HasColumnType("int"); - b.Property("LunchId") .HasColumnType("int"); @@ -229,9 +226,6 @@ namespace CanteenDatabaseImplement.Migrations .IsRequired() .HasColumnType("nvarchar(max)"); - b.Property("Sum") - .HasColumnType("float"); - b.Property("VisitorId") .HasColumnType("int"); @@ -417,13 +411,13 @@ namespace CanteenDatabaseImplement.Migrations b.HasOne("CanteenDatabaseImplement.Models.Dish", "Dish") .WithMany("Products") .HasForeignKey("DishId") - .OnDelete(DeleteBehavior.NoAction) + .OnDelete(DeleteBehavior.Restrict) .IsRequired(); b.HasOne("CanteenDatabaseImplement.Models.Product", "Product") .WithMany("Dishes") .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.NoAction) + .OnDelete(DeleteBehavior.Restrict) .IsRequired(); b.Navigation("Dish"); @@ -447,13 +441,13 @@ namespace CanteenDatabaseImplement.Migrations b.HasOne("CanteenDatabaseImplement.Models.Lunch", "Lunch") .WithMany("Orders") .HasForeignKey("LunchId") - .OnDelete(DeleteBehavior.NoAction) + .OnDelete(DeleteBehavior.Restrict) .IsRequired(); b.HasOne("CanteenDatabaseImplement.Models.Order", "Order") .WithMany("Lunches") .HasForeignKey("OrderId") - .OnDelete(DeleteBehavior.NoAction) + .OnDelete(DeleteBehavior.Restrict) .IsRequired(); b.Navigation("Lunch"); @@ -466,13 +460,13 @@ namespace CanteenDatabaseImplement.Migrations b.HasOne("CanteenDatabaseImplement.Models.Lunch", "Lunch") .WithMany("Products") .HasForeignKey("LunchId") - .OnDelete(DeleteBehavior.NoAction) + .OnDelete(DeleteBehavior.Restrict) .IsRequired(); b.HasOne("CanteenDatabaseImplement.Models.Product", "Product") .WithMany("Lunches") .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.NoAction) + .OnDelete(DeleteBehavior.Restrict) .IsRequired(); b.Navigation("Lunch"); @@ -485,7 +479,7 @@ namespace CanteenDatabaseImplement.Migrations b.HasOne("CanteenDatabaseImplement.Models.Visitor", "Visitor") .WithMany("Orders") .HasForeignKey("VisitorId") - .OnDelete(DeleteBehavior.NoAction) + .OnDelete(DeleteBehavior.Cascade) .IsRequired(); b.Navigation("Visitor"); @@ -496,13 +490,13 @@ namespace CanteenDatabaseImplement.Migrations b.HasOne("CanteenDatabaseImplement.Models.Cook", "Cook") .WithMany("Orders") .HasForeignKey("CookId") - .OnDelete(DeleteBehavior.NoAction) + .OnDelete(DeleteBehavior.Restrict) .IsRequired(); b.HasOne("CanteenDatabaseImplement.Models.Order", "Order") .WithMany("Cooks") .HasForeignKey("OrderId") - .OnDelete(DeleteBehavior.NoAction) + .OnDelete(DeleteBehavior.Restrict) .IsRequired(); b.Navigation("Cook"); @@ -515,13 +509,13 @@ namespace CanteenDatabaseImplement.Migrations b.HasOne("CanteenDatabaseImplement.Models.Order", "Order") .WithMany("Tablewares") .HasForeignKey("OrderId") - .OnDelete(DeleteBehavior.NoAction) + .OnDelete(DeleteBehavior.Restrict) .IsRequired(); b.HasOne("CanteenDatabaseImplement.Models.Tableware", "Tableware") .WithMany("Orders") .HasForeignKey("TablewareId") - .OnDelete(DeleteBehavior.NoAction) + .OnDelete(DeleteBehavior.Restrict) .IsRequired(); b.Navigation("Order"); @@ -545,13 +539,13 @@ namespace CanteenDatabaseImplement.Migrations b.HasOne("CanteenDatabaseImplement.Models.Cook", "Cook") .WithMany("Products") .HasForeignKey("CookId") - .OnDelete(DeleteBehavior.NoAction) + .OnDelete(DeleteBehavior.Restrict) .IsRequired(); b.HasOne("CanteenDatabaseImplement.Models.Product", "Product") .WithMany("Cooks") .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.NoAction) + .OnDelete(DeleteBehavior.Restrict) .IsRequired(); b.Navigation("Cook"); diff --git a/Canteen/CanteenDatabaseImplement/Migrations/20230518211530_Init.cs b/Canteen/CanteenDatabaseImplement/Migrations/20230519185610_Init.cs similarity index 92% rename from Canteen/CanteenDatabaseImplement/Migrations/20230518211530_Init.cs rename to Canteen/CanteenDatabaseImplement/Migrations/20230519185610_Init.cs index a441487..11effe9 100644 --- a/Canteen/CanteenDatabaseImplement/Migrations/20230518211530_Init.cs +++ b/Canteen/CanteenDatabaseImplement/Migrations/20230519185610_Init.cs @@ -137,8 +137,7 @@ namespace CanteenDatabaseImplement.Migrations Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), VisitorId = table.Column(type: "int", nullable: false), - Description = table.Column(type: "nvarchar(max)", nullable: false), - Sum = table.Column(type: "float", nullable: true) + Description = table.Column(type: "nvarchar(max)", nullable: false) }, constraints: table => { @@ -147,7 +146,8 @@ namespace CanteenDatabaseImplement.Migrations name: "FK_Orders_Visitors_VisitorId", column: x => x.VisitorId, principalTable: "Visitors", - principalColumn: "Id"); + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( @@ -187,12 +187,14 @@ namespace CanteenDatabaseImplement.Migrations name: "FK_DishProduct_Dishes_DishId", column: x => x.DishId, principalTable: "Dishes", - principalColumn: "Id"); + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_DishProduct_Products_ProductId", column: x => x.ProductId, principalTable: "Products", - principalColumn: "Id"); + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( @@ -211,12 +213,14 @@ namespace CanteenDatabaseImplement.Migrations name: "FK_ProductCook_Cooks_CookId", column: x => x.CookId, principalTable: "Cooks", - principalColumn: "Id"); + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_ProductCook_Products_ProductId", column: x => x.ProductId, principalTable: "Products", - principalColumn: "Id"); + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( @@ -236,12 +240,14 @@ namespace CanteenDatabaseImplement.Migrations name: "FK_LunchProduct_Lunches_LunchId", column: x => x.LunchId, principalTable: "Lunches", - principalColumn: "Id"); + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_LunchProduct_Products_ProductId", column: x => x.ProductId, principalTable: "Products", - principalColumn: "Id"); + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( @@ -251,8 +257,7 @@ namespace CanteenDatabaseImplement.Migrations Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), LunchId = table.Column(type: "int", nullable: false), - OrderId = table.Column(type: "int", nullable: false), - CountOrders = table.Column(type: "int", nullable: false) + OrderId = table.Column(type: "int", nullable: false) }, constraints: table => { @@ -261,12 +266,14 @@ namespace CanteenDatabaseImplement.Migrations name: "FK_LunchOrder_Lunches_LunchId", column: x => x.LunchId, principalTable: "Lunches", - principalColumn: "Id"); + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_LunchOrder_Orders_OrderId", column: x => x.OrderId, principalTable: "Orders", - principalColumn: "Id"); + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( @@ -285,12 +292,14 @@ namespace CanteenDatabaseImplement.Migrations name: "FK_OrderCook_Cooks_CookId", column: x => x.CookId, principalTable: "Cooks", - principalColumn: "Id"); + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_OrderCook_Orders_OrderId", column: x => x.OrderId, principalTable: "Orders", - principalColumn: "Id"); + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( @@ -310,12 +319,14 @@ namespace CanteenDatabaseImplement.Migrations name: "FK_OrderTableware_Orders_OrderId", column: x => x.OrderId, principalTable: "Orders", - principalColumn: "Id"); + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_OrderTableware_Tablewares_TablewareId", column: x => x.TablewareId, principalTable: "Tablewares", - principalColumn: "Id"); + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateIndex( diff --git a/Canteen/CanteenDatabaseImplement/Migrations/CanteenDatabaseModelSnapshot.cs b/Canteen/CanteenDatabaseImplement/Migrations/CanteenDatabaseModelSnapshot.cs index 54bf5ff..8d6227c 100644 --- a/Canteen/CanteenDatabaseImplement/Migrations/CanteenDatabaseModelSnapshot.cs +++ b/Canteen/CanteenDatabaseImplement/Migrations/CanteenDatabaseModelSnapshot.cs @@ -141,9 +141,6 @@ namespace CanteenDatabaseImplement.Migrations SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - b.Property("CountOrders") - .HasColumnType("int"); - b.Property("LunchId") .HasColumnType("int"); @@ -226,9 +223,6 @@ namespace CanteenDatabaseImplement.Migrations .IsRequired() .HasColumnType("nvarchar(max)"); - b.Property("Sum") - .HasColumnType("float"); - b.Property("VisitorId") .HasColumnType("int"); @@ -414,13 +408,13 @@ namespace CanteenDatabaseImplement.Migrations b.HasOne("CanteenDatabaseImplement.Models.Dish", "Dish") .WithMany("Products") .HasForeignKey("DishId") - .OnDelete(DeleteBehavior.NoAction) + .OnDelete(DeleteBehavior.Restrict) .IsRequired(); b.HasOne("CanteenDatabaseImplement.Models.Product", "Product") .WithMany("Dishes") .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.NoAction) + .OnDelete(DeleteBehavior.Restrict) .IsRequired(); b.Navigation("Dish"); @@ -444,13 +438,13 @@ namespace CanteenDatabaseImplement.Migrations b.HasOne("CanteenDatabaseImplement.Models.Lunch", "Lunch") .WithMany("Orders") .HasForeignKey("LunchId") - .OnDelete(DeleteBehavior.NoAction) + .OnDelete(DeleteBehavior.Restrict) .IsRequired(); b.HasOne("CanteenDatabaseImplement.Models.Order", "Order") .WithMany("Lunches") .HasForeignKey("OrderId") - .OnDelete(DeleteBehavior.NoAction) + .OnDelete(DeleteBehavior.Restrict) .IsRequired(); b.Navigation("Lunch"); @@ -463,13 +457,13 @@ namespace CanteenDatabaseImplement.Migrations b.HasOne("CanteenDatabaseImplement.Models.Lunch", "Lunch") .WithMany("Products") .HasForeignKey("LunchId") - .OnDelete(DeleteBehavior.NoAction) + .OnDelete(DeleteBehavior.Restrict) .IsRequired(); b.HasOne("CanteenDatabaseImplement.Models.Product", "Product") .WithMany("Lunches") .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.NoAction) + .OnDelete(DeleteBehavior.Restrict) .IsRequired(); b.Navigation("Lunch"); @@ -482,7 +476,7 @@ namespace CanteenDatabaseImplement.Migrations b.HasOne("CanteenDatabaseImplement.Models.Visitor", "Visitor") .WithMany("Orders") .HasForeignKey("VisitorId") - .OnDelete(DeleteBehavior.NoAction) + .OnDelete(DeleteBehavior.Cascade) .IsRequired(); b.Navigation("Visitor"); @@ -493,13 +487,13 @@ namespace CanteenDatabaseImplement.Migrations b.HasOne("CanteenDatabaseImplement.Models.Cook", "Cook") .WithMany("Orders") .HasForeignKey("CookId") - .OnDelete(DeleteBehavior.NoAction) + .OnDelete(DeleteBehavior.Restrict) .IsRequired(); b.HasOne("CanteenDatabaseImplement.Models.Order", "Order") .WithMany("Cooks") .HasForeignKey("OrderId") - .OnDelete(DeleteBehavior.NoAction) + .OnDelete(DeleteBehavior.Restrict) .IsRequired(); b.Navigation("Cook"); @@ -512,13 +506,13 @@ namespace CanteenDatabaseImplement.Migrations b.HasOne("CanteenDatabaseImplement.Models.Order", "Order") .WithMany("Tablewares") .HasForeignKey("OrderId") - .OnDelete(DeleteBehavior.NoAction) + .OnDelete(DeleteBehavior.Restrict) .IsRequired(); b.HasOne("CanteenDatabaseImplement.Models.Tableware", "Tableware") .WithMany("Orders") .HasForeignKey("TablewareId") - .OnDelete(DeleteBehavior.NoAction) + .OnDelete(DeleteBehavior.Restrict) .IsRequired(); b.Navigation("Order"); @@ -542,13 +536,13 @@ namespace CanteenDatabaseImplement.Migrations b.HasOne("CanteenDatabaseImplement.Models.Cook", "Cook") .WithMany("Products") .HasForeignKey("CookId") - .OnDelete(DeleteBehavior.NoAction) + .OnDelete(DeleteBehavior.Restrict) .IsRequired(); b.HasOne("CanteenDatabaseImplement.Models.Product", "Product") .WithMany("Cooks") .HasForeignKey("ProductId") - .OnDelete(DeleteBehavior.NoAction) + .OnDelete(DeleteBehavior.Restrict) .IsRequired(); b.Navigation("Cook"); diff --git a/Canteen/CanteenDatabaseImplement/Models/Dish.cs b/Canteen/CanteenDatabaseImplement/Models/Dish.cs index e83b7f6..6d1c99b 100644 --- a/Canteen/CanteenDatabaseImplement/Models/Dish.cs +++ b/Canteen/CanteenDatabaseImplement/Models/Dish.cs @@ -77,7 +77,7 @@ namespace CanteenDatabaseImplement.Models { var dishProduct = context.DishProduct.Where(rec => rec.DishId == model.Id).ToList(); - if (dishProduct.Any()) + if (dishProduct != null && dishProduct.Count > 0) { context.DishProduct.RemoveRange(dishProduct.Where(rec => !model.DishProducts.ContainsKey(rec.ProductId))); foreach (var updateProduct in dishProduct) diff --git a/Canteen/CanteenDatabaseImplement/Models/DishProduct.cs b/Canteen/CanteenDatabaseImplement/Models/DishProduct.cs index 3b564a0..de019ce 100644 --- a/Canteen/CanteenDatabaseImplement/Models/DishProduct.cs +++ b/Canteen/CanteenDatabaseImplement/Models/DishProduct.cs @@ -17,7 +17,7 @@ namespace CanteenDatabaseImplement.Models public int ProductId { get; set; } [Required] public int CountProducts { get; set; } - public virtual Dish Dish { get; set; } = new(); + public virtual Dish Dish { get; set; } public virtual Product Product { get; set; } = new(); } } diff --git a/Canteen/CanteenDatabaseImplement/Models/Lunch.cs b/Canteen/CanteenDatabaseImplement/Models/Lunch.cs index 55d2ee0..1216eef 100644 --- a/Canteen/CanteenDatabaseImplement/Models/Lunch.cs +++ b/Canteen/CanteenDatabaseImplement/Models/Lunch.cs @@ -41,16 +41,16 @@ namespace CanteenDatabaseImplement.Models } } - private Dictionary? _lunchOrders = null; + private Dictionary? _lunchOrders = null; [NotMapped] - public Dictionary LunchOrders + public Dictionary LunchOrders { get { if (_lunchOrders == null) { - _lunchOrders = Orders.ToDictionary(record => record.OrderId, record => (record.Order as IOrderModel, record.CountOrders)); + _lunchOrders = Orders.ToDictionary(record => record.OrderId, record => record.Order as IOrderModel); } return _lunchOrders; } @@ -80,8 +80,7 @@ namespace CanteenDatabaseImplement.Models }).ToList(), Orders = model.LunchOrders.Select(x => new LunchOrder { - Order = context.Orders.First(y => y.Id == x.Key), - CountOrders = x.Value.Item2 + Order = context.Orders.First(y => y.Id == x.Key) }).ToList() }; } @@ -146,7 +145,6 @@ namespace CanteenDatabaseImplement.Models foreach (var updateOrder in lunchOrders) { - updateOrder.CountOrders = model.LunchOrders[updateOrder.OrderId].Item2; model.LunchOrders.Remove(updateOrder.OrderId); } context.SaveChanges(); @@ -158,8 +156,7 @@ namespace CanteenDatabaseImplement.Models context.LunchOrder.Add(new LunchOrder { Lunch = lunch, - Order = context.Orders.First(x => x.Id == pp.Key), - CountOrders = pp.Value.Item2 + Order = context.Orders.First(x => x.Id == pp.Key) }); context.SaveChanges(); } diff --git a/Canteen/CanteenDatabaseImplement/Models/LunchOrder.cs b/Canteen/CanteenDatabaseImplement/Models/LunchOrder.cs index 8f61d83..0a20d9e 100644 --- a/Canteen/CanteenDatabaseImplement/Models/LunchOrder.cs +++ b/Canteen/CanteenDatabaseImplement/Models/LunchOrder.cs @@ -16,7 +16,6 @@ namespace CanteenDatabaseImplement.Models [Required] public int OrderId { get; set; } [Required] - public int CountOrders { get; set; } public virtual Lunch Lunch { get; set; } = new(); public virtual Order Order { get; set; } = new(); public LunchOrderViewModel GetViewModel => new() diff --git a/Canteen/CanteenDatabaseImplement/Models/Order.cs b/Canteen/CanteenDatabaseImplement/Models/Order.cs index c9c2309..6aa1107 100644 --- a/Canteen/CanteenDatabaseImplement/Models/Order.cs +++ b/Canteen/CanteenDatabaseImplement/Models/Order.cs @@ -19,7 +19,6 @@ namespace CanteenDatabaseImplement.Models public int VisitorId { get; private set; } [Required] public string Description { get; private set; } = string.Empty; - public double? Sum { get; private set; } private Dictionary? _orderCooks = null; @@ -72,7 +71,6 @@ namespace CanteenDatabaseImplement.Models Id = model.Id, VisitorId = model.VisitorId, Description = model.Description, - Sum = model.Sum }; } @@ -83,7 +81,6 @@ namespace CanteenDatabaseImplement.Models return; } Description = model.Description; - Sum = model.Sum; } public OrderViewModel GetViewModel => new() @@ -91,14 +88,13 @@ namespace CanteenDatabaseImplement.Models Id = Id, VisitorId = VisitorId, Description = Description, - Sum = Sum, OrderCooks = OrderCooks, OrderTablewares = OrderTablewares }; public void UpdateOrderCook(CanteenDatabase context, OrderBindingModel model) { - var orderCook = context.OrderCook.Where(rec => rec.CookId == model.Id).ToList(); - if (orderCook != null && (orderCook.Count > 0)) + var orderCook = context.OrderCook.Where(rec => rec.OrderId == model.Id).ToList(); + if (orderCook.Count > 0) { context.OrderCook.RemoveRange(orderCook.Where(rec => !model.OrderCooks.ContainsKey(rec.CookId))); context.SaveChanges(); @@ -123,8 +119,8 @@ namespace CanteenDatabaseImplement.Models } public void UpdateOrderTablewares(CanteenDatabase context, OrderBindingModel model) { - var orderTableware = context.OrderTableware.Where(rec => rec.TablewareId == model.Id).ToList(); - if (orderTableware != null && (orderTableware.Count > 0)) + var orderTableware = context.OrderTableware.Where(rec => rec.OrderId == model.Id).ToList(); + if (orderTableware != null && orderTableware.Count > 0) { context.OrderTableware.RemoveRange(orderTableware.Where(rec => !model.OrderTablewares.ContainsKey(rec.TablewareId))); context.SaveChanges(); diff --git a/Canteen/CanteenDatabaseImplement/Models/Product.cs b/Canteen/CanteenDatabaseImplement/Models/Product.cs index e08ffef..ea78cfe 100644 --- a/Canteen/CanteenDatabaseImplement/Models/Product.cs +++ b/Canteen/CanteenDatabaseImplement/Models/Product.cs @@ -79,7 +79,7 @@ namespace CanteenDatabaseImplement.Models public void UpdateProductCooks(CanteenDatabase context, ProductBindingModel model) { var productCookers = context.ProductCook.Where(rec => rec.ProductId == model.Id).ToList(); - if (productCookers != null) + if (productCookers.Count > 0) { context.ProductCook.RemoveRange(productCookers.Where(rec => !model.ProductCooks.ContainsKey(rec.CookId))); context.SaveChanges(); diff --git a/Canteen/CanteenDatabaseImplement/Models/Visitor.cs b/Canteen/CanteenDatabaseImplement/Models/Visitor.cs index 6f6cf8c..e952431 100644 --- a/Canteen/CanteenDatabaseImplement/Models/Visitor.cs +++ b/Canteen/CanteenDatabaseImplement/Models/Visitor.cs @@ -24,11 +24,11 @@ namespace CanteenDatabaseImplement.Models public int Id { get; private set; } [ForeignKey("VisitorId")] - public virtual List Orders { get; set; } = new(); + public virtual List Orders { get; set; } [ForeignKey("VisitorId")] - public virtual List Lunches { get; set; } = new(); + public virtual List Lunches { get; set; } [ForeignKey("VisitorId")] - public virtual List Tablewares { get; set; } = new(); + public virtual List Tablewares { get; set; } public static Visitor? Create(VisitorBindingModel model) { if (model == null) diff --git a/Canteen/CanteenManagerApp/Controllers/HomeController.cs b/Canteen/CanteenManagerApp/Controllers/HomeController.cs index dffb78b..c7dac2f 100644 --- a/Canteen/CanteenManagerApp/Controllers/HomeController.cs +++ b/Canteen/CanteenManagerApp/Controllers/HomeController.cs @@ -272,7 +272,7 @@ namespace CanteenManagerApp.Controllers return Redirect("~/Home/Enter"); } ViewBag.ProductList = APIClient.GetRequest>($"api/main/getproductlist?managerId={APIClient.Manager.Id}"); - return Redirect("~/Home/ProductList"); + return View(); } [HttpPost] diff --git a/Canteen/CanteenRestApi/Controllers/MainController.cs b/Canteen/CanteenRestApi/Controllers/MainController.cs index af268f7..ffe2b18 100644 --- a/Canteen/CanteenRestApi/Controllers/MainController.cs +++ b/Canteen/CanteenRestApi/Controllers/MainController.cs @@ -18,16 +18,20 @@ namespace CanteenRestApi.Controllers private readonly IDishLogic _dish; private readonly IProductLogic _product; private readonly ITablewareLogic _tableware; + private readonly IOrderLogic _order; + private readonly ILunchLogic _lunch; private readonly IGraphicLogic _gl; - public MainController(ILogger logger, ICookLogic cook, IDishLogic dish, IProductLogic product, ITablewareLogic tableware, IGraphicLogic gl) + public MainController(ILogger logger, ICookLogic cook, IDishLogic dish, IProductLogic product, ITablewareLogic tableware, IOrderLogic order, IGraphicLogic gl, ILunchLogic lunch) { _logger = logger; _cook = cook; _dish = dish; _product = product; _tableware = tableware; + _order = order; _gl = gl; + _lunch = lunch; } [HttpGet] @@ -95,6 +99,19 @@ namespace CanteenRestApi.Controllers throw; } } + [HttpGet] + public List? GetCookFullList() + { + try + { + return _cook.ReadList(null); + } + catch (Exception ex) + { + _logger.LogError(ex, "Error during loading list of bouquets"); + throw; + } + } [HttpPost] public void CookCreate(CookBindingModel model) { @@ -226,6 +243,19 @@ namespace CanteenRestApi.Controllers } } [HttpGet] + public List? GetProductFullList() + { + try + { + return _product.ReadList(null); + } + catch (Exception ex) + { + _logger.LogError(ex, "Error during loading list of bouquets"); + throw; + } + } + [HttpGet] public ProductViewModel? GetProduct(int Id) { try @@ -291,6 +321,175 @@ namespace CanteenRestApi.Controllers } } [HttpGet] + public List? GetOrderList(int visitorId) + { + try + { + return _order.ReadList(new OrderSearchModel { VisitorId = visitorId }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Error during loading list of bouquets"); + throw; + } + } + [HttpGet] + public OrderViewModel? GetOrder(int Id) + { + try + { + return _order.ReadElement(new OrderSearchModel { Id = Id }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Error during loading list of bouquets"); + throw; + } + } + [HttpPost] + public void CreateOrder(OrderBindingModel model) + { + try + { + _order.Create(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Error during loading list of bouquets"); + throw; + } + } + [HttpPost] + public void DeleteOrder(OrderBindingModel model) + { + try + { + _order.Delete(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Error during loading list of bouquets"); + throw; + } + } + [HttpPost] + public void UpdateOrder(OrderBindingModel model) + { + try + { + _order.Update(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Error during loading list of bouquets"); + throw; + } + } + [HttpPost] + public void OrderAddTablewares(Tuple model) + { + try + { + _order.UpdateTablewares(model.Item1, model.Item2, model.Item3); + } + catch (Exception ex) + { + _logger.LogError(ex, "Error during loading list of bouquets"); + throw; + } + } + [HttpPost] + public void OrderAddCooks(Tuple model) + { + try + { + _order.UpdateCooks(model.Item1, model.Item2); + } + catch (Exception ex) + { + _logger.LogError(ex, "Error during loading list of bouquets"); + throw; + } + } + [HttpPost] + public void CreateLunch(LunchBindingModel model) + { + try + { + _lunch.Create(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Error during loading list of bouquets"); + throw; + } + } + [HttpPost] + public void DeleteLunch(LunchBindingModel model) + { + try + { + _lunch.Delete(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Error during loading list of bouquets"); + throw; + } + } + [HttpPost] + public void UpdateLunch(LunchBindingModel model) + { + try + { + _lunch.Update(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Error during loading list of bouquets"); + throw; + } + } + [HttpPost] + public void LunchAddOrders(Tuple model) + { + try + { + _lunch.UpdateOrders(model.Item1, model.Item2); + } + catch (Exception ex) + { + _logger.LogError(ex, "Error during loading list of bouquets"); + throw; + } + } + [HttpPost] + public void LunchAddProducts(Tuple model) + { + try + { + _lunch.UpdateProducts(model.Item1, model.Item2, model.Item3); + } + catch (Exception ex) + { + _logger.LogError(ex, "Error during loading list of bouquets"); + throw; + } + } + [HttpGet] + public List? GetLunchList(int visitorId) + { + try + { + return _lunch.ReadList(new LunchSearchModel { VisitorId = visitorId }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Error during loading list of bouquets"); + throw; + } + } + [HttpGet] public GraphicViewModel[] GetGraphic() { return new GraphicViewModel[] diff --git a/Canteen/CanteenRestApi/Program.cs b/Canteen/CanteenRestApi/Program.cs index 5d96850..6cb79b8 100644 --- a/Canteen/CanteenRestApi/Program.cs +++ b/Canteen/CanteenRestApi/Program.cs @@ -16,6 +16,8 @@ builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); @@ -23,7 +25,9 @@ builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); +builder.Services.AddTransient(); builder.Services.AddTransient(); +builder.Services.AddTransient(); builder.Services.AddControllers(); // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle builder.Services.AddEndpointsApiExplorer(); diff --git a/Canteen/CanteenVisitorApp/Controllers/HomeController.cs b/Canteen/CanteenVisitorApp/Controllers/HomeController.cs index 62cbf13..23eb58b 100644 --- a/Canteen/CanteenVisitorApp/Controllers/HomeController.cs +++ b/Canteen/CanteenVisitorApp/Controllers/HomeController.cs @@ -15,7 +15,6 @@ namespace CanteenVisitorApp.Controllers { _logger = logger; } - [HttpGet] public IActionResult Index() { @@ -26,7 +25,6 @@ namespace CanteenVisitorApp.Controllers return View(); } - [HttpGet] public IActionResult Enter() { @@ -48,13 +46,11 @@ namespace CanteenVisitorApp.Controllers Response.Redirect("Index"); } - [HttpGet] public IActionResult Register() { return View(); } - [HttpPost] public void Register(string login, string password, string fio, string phoneNumber) { @@ -73,7 +69,7 @@ namespace CanteenVisitorApp.Controllers Response.Redirect("Enter"); } - + [HttpGet] public IActionResult Privacy() { return View(); @@ -88,7 +84,6 @@ namespace CanteenVisitorApp.Controllers ViewBag.Tablewares = APIClient.GetRequest>($"api/main/gettablewarelist?visitorId={APIClient.Visitor.Id}"); return View(); } - [HttpGet] public IActionResult CreateTableware() { @@ -98,7 +93,6 @@ namespace CanteenVisitorApp.Controllers } return View(); } - [HttpPost] public void CreateTableware(string tablewarename) { @@ -116,7 +110,6 @@ namespace CanteenVisitorApp.Controllers Response.Redirect("Tablewares"); } - [HttpGet] public IActionResult DeleteTableware() { @@ -155,7 +148,6 @@ namespace CanteenVisitorApp.Controllers ViewBag.Tablewares = APIClient.GetRequest>($"api/main/gettablewarelist?visitorId={APIClient.Visitor.Id}"); return View(); } - [HttpPost] public void UpdateTableware(int id, string tablewarename) { @@ -181,7 +173,6 @@ namespace CanteenVisitorApp.Controllers ViewBag.Orders = APIClient.GetRequest>($"api/main/getorderlist?visitorId={APIClient.Visitor.Id}"); return View(); } - [HttpGet] public IActionResult CreateOrder() { @@ -191,25 +182,22 @@ namespace CanteenVisitorApp.Controllers } return View(); } - [HttpPost] - public void CreateOrder(string ordername) + public void CreateOrder(string description) { if (APIClient.Visitor == null) { throw new Exception("Доступ возможен только авторизованным пользователям"); } - APIClient.PostRequest("api/main/createorder", new OrderBindingModel { VisitorId = APIClient.Visitor.Id, - OrderName = ordername + Description = description }); Response.Redirect("Orders"); } - [HttpGet] public IActionResult DeleteOrder() { @@ -229,7 +217,7 @@ namespace CanteenVisitorApp.Controllers } if (id <= 0) { - throw new Exception("Выберите пhb,jh"); + throw new Exception("Выберите заказ"); } APIClient.PostRequest("api/main/DeleteOrder", new OrderBindingModel { @@ -248,21 +236,262 @@ namespace CanteenVisitorApp.Controllers ViewBag.Orders = APIClient.GetRequest>($"api/main/getorderlist?visitorId={APIClient.Visitor.Id}"); return View(); } - [HttpPost] - public void UpdateOrder(int id, string ordername) + public void UpdateOrder(int Id, string description) { if (APIClient.Visitor == null) { throw new Exception("Доступ возможен только авторизованным пользователям"); } - APIClient.PostRequest("api/main/UpdateOrder", new OrderBindingModel + APIClient.PostRequest("api/main/updateorder", new OrderBindingModel + { + Id = Id, + Description = description, + VisitorId = APIClient.Visitor.Id + }); + + Response.Redirect("Orders"); + } + [HttpGet] + public IActionResult OrderAddTablewares() + { + if (APIClient.Visitor == null) + { + return Redirect("~/Home/Enter"); + } + ViewBag.OrderList = APIClient.GetRequest>($"api/main/getorderlist?visitorId={APIClient.Visitor.Id}"); + ViewBag.TablewareList = APIClient.GetRequest>($"api/main/gettablewarelist?visitorId={APIClient.Visitor.Id}"); + return View(); + } + [HttpPost] + public void OrderAddTablewares(int selectedOrder, int selectedTableware, int count) + { + if (APIClient.Visitor == null) + { + throw new Exception("Доступ возможен только авторизованным пользователям"); + } + + if (selectedOrder <= 0) + { + throw new Exception("Должно быть выбран заказ"); + } + if (selectedTableware <= 0) + { + throw new Exception("Должен быть выбран прибор"); + } + if (count < -1) + { + throw new Exception("Количество прибора должно быть больше 0"); + } + + APIClient.PostRequest("api/main/orderaddtablewares", Tuple.Create + ( + new OrderBindingModel { Id = selectedOrder }, + new TablewareBindingModel { Id = selectedTableware }, + count + )); + + Response.Redirect("Orders"); + } + [HttpGet] + public IActionResult OrderAddCooks() + { + if (APIClient.Visitor == null) + { + return Redirect("~/Home/Enter"); + } + ViewBag.OrderList = APIClient.GetRequest>($"api/main/getorderlist?visitorId={APIClient.Visitor.Id}"); + //ViewBag.CookList = new List(); + ViewBag.CookList = APIClient.GetRequest>("api/main/getcookfulllist"); + return View(); + } + [HttpPost] + public void OrderAddCooks(int selectedOrder, int selectedCook) + { + if (APIClient.Visitor == null) + { + throw new Exception("Доступ возможен только авторизованным пользователям"); + } + + if (selectedOrder <= 0) + { + throw new Exception("Должно быть выбран заказ"); + } + if (selectedCook <= 0) + { + throw new Exception("Должен быть выбран повар"); + } + + APIClient.PostRequest("api/main/OrderAddCooks", Tuple.Create + ( + new OrderBindingModel { Id = selectedOrder }, + new TablewareBindingModel { Id = selectedCook } + )); + + Response.Redirect("Orders"); + } + [HttpGet] + public IActionResult Lunches() + { + if (APIClient.Visitor == null) + { + return Redirect("~/Home/Enter"); + } + ViewBag.Lunches = APIClient.GetRequest>($"api/main/getlunchlist?visitorId={APIClient.Visitor.Id}"); + return View(); + } + [HttpGet] + public IActionResult CreateLunch() + { + if (APIClient.Visitor == null) + { + return Redirect("~/Home/Enter"); + } + return View(); + } + [HttpPost] + public void CreateLunch(string name) + { + if (APIClient.Visitor == null) + { + throw new Exception("Доступ возможен только авторизованным пользователям"); + } + + APIClient.PostRequest("api/main/createlunch", new LunchBindingModel + { + VisitorId = APIClient.Visitor.Id, + LunchName = name + }); + + Response.Redirect("Lunches"); + } + [HttpGet] + public IActionResult DeleteLunch() + { + if (APIClient.Visitor == null) + { + return Redirect("~/Home/Enter"); + } + ViewBag.Lunches = APIClient.GetRequest>($"api/main/getlunchlist?visitorId={APIClient.Visitor.Id}"); + return View(); + } + [HttpPost] + public void DeleteLunch(int id) + { + if (APIClient.Visitor == null) + { + throw new Exception("Доступ возможен только авторизованным пользователям"); + } + if (id <= 0) + { + throw new Exception("Выберите заказ"); + } + APIClient.PostRequest("api/main/DeleteLunch", new LunchBindingModel + { + Id = id + }); + + Response.Redirect("Lunches"); + } + [HttpGet] + public IActionResult UpdateLunch() + { + if (APIClient.Visitor == null) + { + return Redirect("~/Home/Enter"); + } + ViewBag.Lunches = APIClient.GetRequest>($"api/main/getlunchlist?visitorId={APIClient.Visitor.Id}"); + return View(); + } + [HttpPost] + public void UpdateLunch(int id, string name) + { + if (APIClient.Visitor == null) + { + throw new Exception("Доступ возможен только авторизованным пользователям"); + } + APIClient.PostRequest("api/main/UpdateLunch", new LunchBindingModel { Id = id, VisitorId = APIClient.Visitor.Id, - OrderName = ordername + LunchName = name }); - Response.Redirect("Orders"); + Response.Redirect("Lunches"); + } + [HttpGet] + public IActionResult LunchAddProducts() + { + if (APIClient.Visitor == null) + { + return Redirect("~/Home/Enter"); + } + ViewBag.LunchList = APIClient.GetRequest>($"api/main/getlunchlist?visitorId={APIClient.Visitor.Id}"); + ViewBag.ProductList = APIClient.GetRequest>("api/main/getproductfulllist"); + return View(); + } + [HttpPost] + public void LunchAddProducts(int selectedLunch, int selectedProduct, int count) + { + if (APIClient.Visitor == null) + { + throw new Exception("Доступ возможен только авторизованным пользователям"); + } + + if (selectedLunch <= 0) + { + throw new Exception("Должен быть выбран обед"); + } + if (selectedProduct <= 0) + { + throw new Exception("Должен быть выбран продукт"); + } + if (count <= 0) + { + throw new Exception("Количество продукта должно быть больше 0"); + } + + APIClient.PostRequest("api/main/lunchaddproducts", Tuple.Create + ( + new LunchBindingModel { Id = selectedLunch }, + new ProductBindingModel { Id = selectedProduct }, + count + )); + Response.Redirect("Lunches"); + } + [HttpGet] + public IActionResult LunchAddOrders() + { + if (APIClient.Visitor == null) + { + 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}"); + return View(); + } + [HttpPost] + public void LunchAddOrders(int selectedLunch, int selectedOrder) + { + if (APIClient.Visitor == null) + { + throw new Exception("Доступ возможен только авторизованным пользователям"); + } + + if (selectedLunch <= 0) + { + throw new Exception("Должен быть выбран обед"); + } + if (selectedOrder <= 0) + { + throw new Exception("Должен быть выбран заказ"); + } + + APIClient.PostRequest("api/main/lunchaddorders", Tuple.Create + ( + new LunchBindingModel { Id = selectedLunch }, + new OrderBindingModel { Id = selectedOrder } + )); + Response.Redirect("Lunches"); } [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] public IActionResult Error() diff --git a/Canteen/CanteenVisitorApp/Views/Home/CreateLunch.cshtml b/Canteen/CanteenVisitorApp/Views/Home/CreateLunch.cshtml index c3bb28f..10307de 100644 --- a/Canteen/CanteenVisitorApp/Views/Home/CreateLunch.cshtml +++ b/Canteen/CanteenVisitorApp/Views/Home/CreateLunch.cshtml @@ -1,5 +1,4 @@ -@* -@{ +@{ ViewData["Title"] = "CreateLunch"; }
@@ -17,67 +16,10 @@
-
-
Продукты:
-
- -
-
-
-
-
- -
-
-*@ -@{ - ViewData["Title"] = "CreateLunch"; -} -
-

Добавление обеда

-
- -
-
-
Название обеда:
-
- -
-
-
-
Продукты:
-
- - - -
    -
    -
    -
    - - \ No newline at end of file + \ No newline at end of file diff --git a/Canteen/CanteenVisitorApp/Views/Home/CreateOrder.cshtml b/Canteen/CanteenVisitorApp/Views/Home/CreateOrder.cshtml index 353ef5e..2ce98f9 100644 --- a/Canteen/CanteenVisitorApp/Views/Home/CreateOrder.cshtml +++ b/Canteen/CanteenVisitorApp/Views/Home/CreateOrder.cshtml @@ -14,7 +14,7 @@
    Описание заказа:
    - +
    diff --git a/Canteen/CanteenVisitorApp/Views/Home/CreateTableware.cshtml b/Canteen/CanteenVisitorApp/Views/Home/CreateTableware.cshtml index eb66b9e..a2e12c1 100644 --- a/Canteen/CanteenVisitorApp/Views/Home/CreateTableware.cshtml +++ b/Canteen/CanteenVisitorApp/Views/Home/CreateTableware.cshtml @@ -1,6 +1,6 @@  @{ - ViewData["Title"] = "Tableware"; + ViewData["Title"] = "CreateTableware"; }

    Добавление прибора

    diff --git a/Canteen/CanteenVisitorApp/Views/Home/DeleteLunch.cshtml b/Canteen/CanteenVisitorApp/Views/Home/DeleteLunch.cshtml new file mode 100644 index 0000000..3fbf448 --- /dev/null +++ b/Canteen/CanteenVisitorApp/Views/Home/DeleteLunch.cshtml @@ -0,0 +1,25 @@ +@{ + ViewData["Title"] = "DeleteLunch"; +} +
    +

    Удаление заказа

    +
    + +
    +
    +
    Выберите обед
    +
    + +
    +
    +
    +
    +
    + +
    +
    +
    \ No newline at end of file diff --git a/Canteen/CanteenVisitorApp/Views/Home/DeleteOrder.cshtml b/Canteen/CanteenVisitorApp/Views/Home/DeleteOrder.cshtml index bbfb9af..708d95b 100644 --- a/Canteen/CanteenVisitorApp/Views/Home/DeleteOrder.cshtml +++ b/Canteen/CanteenVisitorApp/Views/Home/DeleteOrder.cshtml @@ -13,7 +13,7 @@
    Выберите заказ
    - +
    diff --git a/Canteen/CanteenVisitorApp/Views/Home/LunchAddOrders.cshtml b/Canteen/CanteenVisitorApp/Views/Home/LunchAddOrders.cshtml new file mode 100644 index 0000000..02eaaf5 --- /dev/null +++ b/Canteen/CanteenVisitorApp/Views/Home/LunchAddOrders.cshtml @@ -0,0 +1,42 @@ +@using CanteenContracts.View; +@{ + ViewData["Title"] = "LunchAddOrders"; +} +
    +

    Привязка заказа к обеду

    +
    + +
    +
    +
    Обед:
    +
    + +
    +
    +
    +
    Заказ:
    +
    + +
    +
    +
    +
    +
    + +
    +
    +
    \ No newline at end of file diff --git a/Canteen/CanteenVisitorApp/Views/Home/Lunches.cshtml b/Canteen/CanteenVisitorApp/Views/Home/Lunches.cshtml index 1daada2..1720636 100644 --- a/Canteen/CanteenVisitorApp/Views/Home/Lunches.cshtml +++ b/Canteen/CanteenVisitorApp/Views/Home/Lunches.cshtml @@ -5,9 +5,10 @@

    Список обедов

    - - - + + + + diff --git a/Canteen/CanteenVisitorApp/Views/Home/OrderAddCooks.cshtml b/Canteen/CanteenVisitorApp/Views/Home/OrderAddCooks.cshtml new file mode 100644 index 0000000..2f23b32 --- /dev/null +++ b/Canteen/CanteenVisitorApp/Views/Home/OrderAddCooks.cshtml @@ -0,0 +1,42 @@ +@using CanteenContracts.View; +@{ + ViewData["Title"] = "OrderAddCooks"; +} +
    +

    Привязка повара к заказу

    +
    + + +
    +
    Заказ:
    +
    + +
    +
    +
    +
    Повар:
    +
    + +
    +
    +
    +
    +
    + +
    +
    + \ No newline at end of file diff --git a/Canteen/CanteenVisitorApp/Views/Home/OrderAddTablewares.cshtml b/Canteen/CanteenVisitorApp/Views/Home/OrderAddTablewares.cshtml new file mode 100644 index 0000000..e8baa7f --- /dev/null +++ b/Canteen/CanteenVisitorApp/Views/Home/OrderAddTablewares.cshtml @@ -0,0 +1,48 @@ +@using CanteenContracts.View; +@{ + ViewData["Title"] = "OrderAddTablewares"; +} +
    +

    Привязка прибора к заказу

    +
    + + +
    +
    Заказ:
    +
    + +
    +
    +
    +
    Прибор:
    +
    + +
    +
    +
    +
    Количество:
    +
    + +
    +
    +
    +
    +
    + +
    +
    + \ No newline at end of file diff --git a/Canteen/CanteenVisitorApp/Views/Home/Orders.cshtml b/Canteen/CanteenVisitorApp/Views/Home/Orders.cshtml index 1e7a82a..5f0bd0a 100644 --- a/Canteen/CanteenVisitorApp/Views/Home/Orders.cshtml +++ b/Canteen/CanteenVisitorApp/Views/Home/Orders.cshtml @@ -3,18 +3,17 @@ }
    -

    Список обедов

    +

    Список заказов

    + +
    - - - - + @@ -23,9 +22,6 @@ - - - } diff --git a/Canteen/CanteenVisitorApp/Views/Home/UpdateLunch.cshtml b/Canteen/CanteenVisitorApp/Views/Home/UpdateLunch.cshtml new file mode 100644 index 0000000..0865272 --- /dev/null +++ b/Canteen/CanteenVisitorApp/Views/Home/UpdateLunch.cshtml @@ -0,0 +1,23 @@ +@using Newtonsoft.Json; +@{ + ViewData["Title"] = "UpdateLunch"; +} +
    +

    Данные обеда

    +
    + +
    +
    Заказ:
    +
    +
    +
    +
    Название обеда:
    +
    + +
    +
    +
    +
    +
    +
    + \ No newline at end of file diff --git a/Canteen/CanteenVisitorApp/Views/Home/UpdateOrder.cshtml b/Canteen/CanteenVisitorApp/Views/Home/UpdateOrder.cshtml index 6f811ca..1105eea 100644 --- a/Canteen/CanteenVisitorApp/Views/Home/UpdateOrder.cshtml +++ b/Canteen/CanteenVisitorApp/Views/Home/UpdateOrder.cshtml @@ -8,12 +8,12 @@
    Заказ:
    -
    +
    -
    Прибор:
    +
    Пожелания:
    - +
    НомерОписание обедаСуммаНазвание прибораКоличество прибораОписание заказа
    @order.Id @order.Description@order.Sum@order.TablewareName@order.CountTablewares