public ActionResult Create() { UserPermissionAction("supplier", RoleAction.create.ToString()); CheckPermission(); var Categories = _CategoryService.Categories(); var SubCategories = _SubCategoryService.GetSubCategories(); var CategoryIds = SubCategories.Where(c => c.CategoryId != null).ToList().Select(c => c.CategoryId); SupplierModel SupplierModel = new CommunicationApp.Models.SupplierModel(); ViewBag.CategoryId = new SelectList(Categories.Where(c => CategoryIds.Contains(c.CategoryId)), "Categoryid", "CategoryName"); ViewBag.SubCategoryId = new SelectList(SubCategories, "SubCategoryId", "SubCategoryName"); ViewBag.Region = new SelectList(_DivisionService.GetDivisions(), "DivisionId", "DivisionName"); return(View(SupplierModel)); }
public ActionResult Edit(int Id) { UserPermissionAction("supplier", RoleAction.create.ToString()); CheckPermission(); var Supplier = _SupplierService.GetSupplier(Id); Mapper.CreateMap <CommunicationApp.Entity.Supplier, CommunicationApp.Models.SupplierModel>(); CommunicationApp.Models.SupplierModel SupplierModel = Mapper.Map <CommunicationApp.Entity.Supplier, CommunicationApp.Models.SupplierModel>(Supplier); ViewBag.CategoryIdList = new SelectList(_CategoryService.Categories(), "Categoryid", "CategoryName", SupplierModel.CategoryId); ViewBag.SubCategoryIdList = new SelectList(_SubCategoryService.GetSubCategories(), "SubCategoryId", "SubCategoryName", SupplierModel.SubCategoryId); ViewBag.RegionList = new SelectList(_DivisionService.GetDivisions(), "DivisionId", "DivisionName", SupplierModel.Region); ViewBag.SubRegionList = new SelectList(_DivisionService.GetDivisions(), "DivisionId", "DivisionName", SupplierModel.SubRegion); return(View(SupplierModel)); }