private void SavePriceProduct() { using (var db = new CowRationContext()) { foreach (var item in storages) { Korm korm = db.Korms.Where(k => k.Id_korm == item.Id).FirstOrDefault(); korm.Price_korm = item.Price; } db.SaveChanges(); } }
public async Task <IActionResult> AddKorms(KormForManagment kormModel) { var characterizations = new List <CharacterizationIndexFood>(); foreach (var characteristicIndex in kormModel.CharacterizationIndexFoods) { var catalogIndex = await context.GetCatalogIndexByName(characteristicIndex.NameIndex); characterizations.Add(new CharacterizationIndexFood { CatalogIndexFoodId = catalogIndex.Id, Value = characteristicIndex.Value, }); } var korm = new Korm { Name = kormModel.Name, Price = kormModel.Price, CharacterizationIndexFoods = characterizations }; context.AddKorm(korm); return(Ok()); }
public void UpdateKorm(int id, Korm korm) { throw new System.NotImplementedException(); }
public async void AddKorm(Korm korm) { await context.Korms.AddAsync(korm); await context.SaveChangesAsync(); }