private ProductCUVM GetCreateProductModel(ProductCUDTO product) { ProductCUVM model = new ProductCUVM() { Product = product }; return(model); }
public IActionResult Detail(int Id) { ProductCUVM model = new ProductCUVM() { Product = _productOperation.GetProduct(Id) }; return(View(model)); }
public IActionResult Create(ProductCUVM model) { if (!ModelState.IsValid) { return(View(GetCreateProductModel(model.Product))); } model.Product.Image = FileUploader.UploadFile(model.Product.File, _hostingEnvironment); _productOperation.CreateProduct(model.Product); return(RedirectToAction(nameof(Index))); }
public IActionResult Edit(ProductCUVM model) { if (!ModelState.IsValid) { return(View(GetUpdateProductModel(model.Product))); } var image = FileUploader.UploadFile(model.Product.File, _hostingEnvironment); var picture = !string.IsNullOrEmpty(image) ? image : model.Product.Image; model.Product.Image = picture; _productOperation.UpdateProduct(model.Product); var viewModel = GetUpdateProductModel(model.Product); ViewBag.Message = "პროდუქტი წარმატებით განახლდა!"; return(View(viewModel)); }