public async Task <IActionResult> Edit(int id, ModeratorProductModel model) { if (!ModelState.IsValid) { return(View(model)); } await this.products.Edit(id, model.Name, model.ImageUrl, model.Price, model.Quantity, model.Description); return(RedirectToAction(nameof(ProductsController.Details), "Products", new { area = string.Empty, id = id.ToString() })); }
public async Task <IActionResult> CreateProduct(int id, ModeratorProductModel model) { var category = this.categories.ById(id); if (category == null) { return(NotFound()); } if (!ModelState.IsValid) { return(View(model)); } await this.products .CreateAsync(model.ImageUrl, model.Name, model.Price, model.Description, model.Quantity, id); TempData.AddSuccuessMessage($"You successfuly create {model.Name} product!"); return(RedirectToAction(nameof(CategoriesController.Details), "Categories", new { area = string.Empty, id = id.ToString() })); }