public bool Update(ProductPanelUpdateDTO dto) { bool result = false; //TodoGetById //Map Dto To Model //Remove All Category If Deleted //Add All Category If Added //Update return(result); }
public ProductPanelUpdateDTO GetForUpdateById(int id) { var product = _repository.GetById(id).Include(x => x.ProductCategory).FirstOrDefault(); var categories = CategoryService.GetForMultiSelect(); categories.CategoryIds = product.ProductCategory.Select(x => x.CategoryId).ToList(); var result = new ProductPanelUpdateDTO { Name = product.Name, Price = product.Price, Quantity = product.Quantity, ImagePath = product.ImagePath, CategoryMultiSelectDTO = categories }; return(result); }
public IActionResult Update([FromForm] ProductPanelUpdateDTO dto) { if (ModelState.IsValid) { var result = ProductService.Update(dto); if (result) { return(RedirectToAction("ProductList", new { skip = 0, take = 10 })); } else { throw new ArgumentException(); } } else { return(View("UpdateProduct", dto)); } }