diff --git a/HardwareShop/HardwareShopContracts/BindingModels/GoodBindingModel.cs b/HardwareShop/HardwareShopContracts/BindingModels/GoodBindingModel.cs index 098d088..49f4107 100644 --- a/HardwareShop/HardwareShopContracts/BindingModels/GoodBindingModel.cs +++ b/HardwareShop/HardwareShopContracts/BindingModels/GoodBindingModel.cs @@ -12,7 +12,7 @@ namespace HardwareShopContracts.BindingModels public int UserId { get; set; } - public Dictionary GoodComponents + public Dictionary GoodsComponents { get; set; diff --git a/HardwareShop/HardwareShopDatabaseImplement/Models/Storekeeper/Good.cs b/HardwareShop/HardwareShopDatabaseImplement/Models/Storekeeper/Good.cs index a870057..6c3d753 100644 --- a/HardwareShop/HardwareShopDatabaseImplement/Models/Storekeeper/Good.cs +++ b/HardwareShop/HardwareShopDatabaseImplement/Models/Storekeeper/Good.cs @@ -55,7 +55,7 @@ namespace HardwareShopDatabaseImplement.Models.Storekeeper GoodName = model.GoodName, Price = model.Price, UserId = model.UserId, - Components = model.GoodComponents.Select(x => new GoodComponent + Components = model.GoodsComponents.Select(x => new GoodComponent { Component = context.Components.First(y => y.Id == x.Key), Count = x.Value.Item2 @@ -80,7 +80,7 @@ namespace HardwareShopDatabaseImplement.Models.Storekeeper Price = Price, UserId = UserId, UserLogin = User.Login, - GoodComponents = GoodsComponents + GoodsComponents = GoodsComponents }; public void UpdateComponents(HardwareShopDatabase context, GoodBindingModel model) @@ -91,18 +91,18 @@ namespace HardwareShopDatabaseImplement.Models.Storekeeper { // удалили те, которых нет в модели context.GoodsComponents .RemoveRange(goodComponents - .Where(rec => !model.GoodComponents.ContainsKey(rec.ComponentId))); + .Where(rec => !model.GoodsComponents.ContainsKey(rec.ComponentId))); context.SaveChanges(); // обновили количество у существующих записей foreach (var updateComponent in goodComponents) { - updateComponent.Count = model.GoodComponents[updateComponent.ComponentId].Item2; - model.GoodComponents.Remove(updateComponent.ComponentId); + updateComponent.Count = model.GoodsComponents[updateComponent.ComponentId].Item2; + model.GoodsComponents.Remove(updateComponent.ComponentId); } context.SaveChanges(); } var good = context.Goods.First(x => x.Id == Id); - foreach (var gc in model.GoodComponents) + foreach (var gc in model.GoodsComponents) { context.GoodsComponents.Add(new GoodComponent {