public void UpdateProduct(ProductForEditionVm productModel) { Product product = PrepareProductForSaving(productModel); UpdateJoningTables(product); _productRepository.UpdateProduct(product); }
public IActionResult EditProduct(ProductForEditionVm editedProduct) { if (editedProduct.Btn == "Submit") { _productService.UpdateProduct(editedProduct); } return(RedirectToAction("Index")); }
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); }
public IActionResult EditProduct(int productId) { ProductForEditionVm productForEdtiting = _productService.GetProductForEdtitionById(productId); return(View(productForEdtiting)); }