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")); } }
public ActionResult AddOrEditCategory(Guid?id) { try { CategoryViewModel model = new CategoryViewModel(); model.DropDownCategory = DropDownListDomain.DropDownList_Categoty(_categoryService.SelectAll().OrderBy(p => p.Name).ToList()); model.DropDownProduct = DropDownListDomain.DropDownList_Product(_productService.SelectAll().OrderBy(p => p.Name).ToList()); if (id.HasValue) { var category = _categoryService.GetById(id.Value); model.Id = category.Id; model.Name = category.Name; model.ParentId = category.ParentId; model.Summary = category.Summary; model.UpdatedDate = category.UpdatedDate; model.CreatedDate = category.CreatedDate; model.IsActive = category.IsActive; return(View(model)); } else { return(View(model)); } } catch { return(RedirectToAction("Erorr500", "HomdeAdmin")); } }