Exemplo n.º 1
0
        public void UpdateProduct(ProductForEditionVm productModel)
        {
            Product product = PrepareProductForSaving(productModel);

            UpdateJoningTables(product);
            _productRepository.UpdateProduct(product);
        }
Exemplo n.º 2
0
 public IActionResult EditProduct(ProductForEditionVm editedProduct)
 {
     if (editedProduct.Btn == "Submit")
     {
         _productService.UpdateProduct(editedProduct);
     }
     return(RedirectToAction("Index"));
 }
Exemplo n.º 3
0
        public ProductForEditionVm GetProductForEdtitionById(int productId)
        {
            Product             product           = _productRepository.GetProductById(productId);
            ProductForEditionVm productForEdition = _mapper.Map <ProductForEditionVm>(product);

            productForEdition.Allergens          = _allergernService.GetAllProductAllergens(productId);
            productForEdition.DietInfoForViewVms = GetAllProductDietInfo(productId);
            productForEdition.Ingredients        = _ingredientService.GetProductAllIngredients(productId);
            List <AllergenForViewVm> residualAllergens = _allergernService.GetAllAllergens().Except(productForEdition.Allergens, new Helper()).ToList();

            productForEdition.AllAllergens = residualAllergens;
            List <IngredientForViewVm> residualIngredients = _ingredientService.GetAllIngredients().Except(productForEdition.Ingredients, new Helper()).ToList();

            productForEdition.AllIngredients        = residualIngredients;
            productForEdition.AllDietInfoForViewVms = GetAllDietInfo();
            productForEdition.PriceString           = productForEdition.Price.ToString();

            productForEdition.ImagePath = $"../Imgs/{productForEdition.ImagePath}";

            return(productForEdition);
        }
Exemplo n.º 4
0
        public IActionResult EditProduct(int productId)
        {
            ProductForEditionVm productForEdtiting = _productService.GetProductForEdtitionById(productId);

            return(View(productForEdtiting));
        }