Пример #1
0
        public void UpdateIngredientSupplier(IngredientSupplier ingredientSupplier)
        {
            var ingredientSupplierUpdate =
                _databaseContext.IngredientSuppliers.FirstOrDefault(i => i.Id == ingredientSupplier.Id);

            if (ingredientSupplierUpdate != null)
            {
                ingredientSupplierUpdate.TotalAmount  = ingredientSupplier.TotalAmount;
                ingredientSupplierUpdate.Price        = ingredientSupplier.Price;
                ingredientSupplierUpdate.IngredientId = ingredientSupplier.IngredientId;
                _databaseContext.IngredientSuppliers.Update(ingredientSupplierUpdate);
            }

            _databaseContext.SaveChanges();
        }
Пример #2
0
        public ActionResult AddSupplierIngredient(int supplierId, [FromBody]
                                                  IngredientSupplierViewModel ingredientSupplierViewModel)
        {
            if (ingredientSupplierViewModel == null)
            {
                return(BadRequest("IngredientSupplier cannot be null."));
            }

            var ingredientSupplier = new IngredientSupplier()
            {
                IngredientId = ingredientSupplierViewModel.IngredientId,
                Price        = ingredientSupplierViewModel.Price,
                SupplierId   = ingredientSupplierViewModel.SupplierId,
                TotalAmount  = ingredientSupplierViewModel.TotalAmount
            };


            _ingredientSupplierService.AddIngredientSupplier(ingredientSupplier);
            return(StatusCode(201));
        }
Пример #3
0
 public void AddIngredientSupplier(IngredientSupplier ingredientSupplier)
 {
     _databaseContext.IngredientSuppliers.Add(ingredientSupplier);
     _databaseContext.SaveChanges();
 }
Пример #4
0
 public void UpdateIngredientSupplier(IngredientSupplier ingredientSupplier)
 {
     _ingredientSupplierRepository.UpdateIngredientSupplier(ingredientSupplier);
 }
Пример #5
0
 public void AddIngredientSupplier(IngredientSupplier ingredientSupplier)
 {
     _ingredientSupplierRepository.AddIngredientSupplier(ingredientSupplier);
 }