public ActionResult AddOrEditProduct(Guid?id) { ProductViewModel model = new ProductViewModel(); model.DropDownBrand = DropDownListDomain.DropDownList_Brand(_brandService.SelectAll()); model.DropDownVendor = DropDownListDomain.DropDownList_Vendor(_vendorService.SelectAll()); model.Volumes = DropDownListDomain.GetVolumeCheckBoxes(); if (id.HasValue) { var product = _productService.GetById(id.Value); model.Id = product.Id; model.Name = product.Name; model.Brand_Id = product.Brand_Id; model.Vendor_Id = product.Vendor_Id; model.Description = product.Description; model.ImagePath = product.ImagePath; model.CreateDate = product.CreatedDate; model.IsActive = product.IsActive; return(View(model)); } else { return(View(model)); } }
public ActionResult AddOrEditProduct(Guid?id) { try { ProductViewModel model = new ProductViewModel(); model.DropDownBrand = DropDownListDomain.DropDownList_Brand(_brandService.SelectAll()); model.DropDownVendor = DropDownListDomain.DropDownList_Vendor(_vendorService.SelectAll()); model.Volumes = DropDownListDomain.GetVolumeCheckBoxes(); model.DropDowncategories = DropDownListDomain.DropDownList_Categoty(_categoryService.SelectAll()); if (id.HasValue) { var product = _productService.GetById(id.Value); model.Id = product.Id; model.Name = product.Name; model.Brand_Id = product.Brand_Id; model.Vendor_Id = product.Vendor_Id; model.Description = product.Description; model.ImagePath = product.ImagePath; model.CreateDate = product.CreatedDate; model.IsActive = true; return(View(model)); } else { return(View(model)); } } catch { return(RedirectToAction("Erorr500", "HomdeAdmin")); } }