public async Task <IActionResult> PutTypeIngredient(int id, TypeIngredient typeIngredient) { if (id != typeIngredient.Id) { return(BadRequest()); } _context.Entry(typeIngredient).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TypeIngredientExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <TypeIngredient> > PostTypeIngredient(TypeIngredient typeIngredient) { _context.TypeIngredient.Add(typeIngredient); await _context.SaveChangesAsync(); return(CreatedAtAction("GetTypeIngredient", new { id = typeIngredient.Id }, typeIngredient)); }
/// <summary> /// Добавляем еще не существующий в репозитории ингредиент /// </summary> /// <param name="_NameIngredient">Наименование ингредиета</param> /// <param name="_MassInKg">Упаковочная масса</param> /// <param name="_StartingPrice">Упаковочная цена</param> /// <param name="_RecordDate">Дата записи</param> /// <param name="_Protein">Количество белков на 100 г продукта</param> /// <param name="_Fat">Количество жиров на 100 г продукта</param> /// <param name="_Carbohydrate">Количество углеводов на 100 г продукта</param> /// <returns>добавилось или нет</returns> public bool AddNewIngredientInRepository(string _NameIngredient, double _MassInKg, decimal _StartingPrice, DateTime _RecordDate, double _Protein, double _Fat, double _Carbohydrate, TypeIngredient _TypeIngredient) { Product NewIngredient = new Product() { Ingredient = new ModelDB.Ingredient(), NameIngredient = _NameIngredient, MassInKg = _MassInKg, StartingPrice = _StartingPrice, RecordDate = _RecordDate, Protein = _Protein, Fat = _Fat, Carbohydrate = _Carbohydrate, TypeIngredient = _TypeIngredient, Subdivision = SubdivisionController.CurrentSubdivision }; return(_IngredientController.AddNewIngredient(NewIngredient)); }