Exemple #1
0
        public ActionResult UpdateSupplierIngredient(int supplierId, [FromBody]
                                                     IngredientSupplierViewModel ingredientSupplierViewModel,
                                                     int ingredientSupplierId)
        {
            if (ingredientSupplierViewModel == null)
            {
                return(BadRequest("IngredientSupplier cannot be null."));
            }

            var ingredientSupplier = _ingredientSupplierService.GetIngredientSupplierById(ingredientSupplierId);

            ingredientSupplier.IngredientId = ingredientSupplierViewModel.IngredientId;
            ingredientSupplier.Price        = ingredientSupplierViewModel.Price;
            ingredientSupplier.SupplierId   = ingredientSupplierViewModel.SupplierId;
            ingredientSupplier.TotalAmount  = ingredientSupplierViewModel.TotalAmount;

            _ingredientSupplierService.UpdateIngredientSupplier(ingredientSupplier);
            return(StatusCode(204));
        }
Exemple #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));
        }