public ActionResult Create(CustomerRole customerRole) { if (!String.IsNullOrWhiteSpace(customerRole.Name)) { var customerRol = new CustomerRoleDao().GetCustomerRoleByName(customerRole.Name); if (customerRol != null) { ModelState.AddModelError("", "Name Customer Role is already registed"); } } if (ModelState.IsValid) { var roleDao = new CustomerRoleDao(); int id = roleDao.InsertCustomerRole(customerRole); if (id > 0) { SetNotification("Thêm mới nhóm người dùng thành công .", "success"); return(RedirectToAction("Index", "CustomerRole")); } else { ModelState.AddModelError("", "Thêm mới nhóm người dùng không thành công ."); } } return(View()); }
public void SetViewBagCustomerRoles(IList <int> selectedId = null) { var customerRoleDao = new CustomerRoleDao(); var customerRoles = customerRoleDao.ListAll(); ViewBag.SelectedCustomerRoleIds = new SelectList(customerRoles, "Id", "Name", selectedId); }
// GET: Admin/CustomerRole public ActionResult Index(string searchString, int pageNumber = 1, int pageSize = 10) { var roleDao = new CustomerRoleDao(); var customerRole = roleDao.GetCustomerRoles(searchString, pageNumber, pageSize); ViewBag.SearchString = searchString; return(View(customerRole)); }
public ActionResult Edit(CustomerRole customerRole) { if (ModelState.IsValid) { var roleDao = new CustomerRoleDao(); var result = roleDao.UpdateCustomerRole(customerRole); if (result) { SetNotification("Cập nhật nhóm người dùng thành công .", "success"); return(RedirectToAction("Index", "CustomerRole")); } else { ModelState.AddModelError("", "Cập nhật nhóm người dùng không thành công ."); } } return(View()); }
public void SetViewBag(int?selectedId = null) { var customerRoleDao = new CustomerRoleDao(); var customerRoles = customerRoleDao.ListAll(); Vendor vendor = new Vendor { Name = "Not a vendor", Id = 0, }; var vendorDao = new VendorDao(); var vendors = vendorDao.GetVendors(); vendors.Add(vendor); ViewBag.AvailableCustomerRoles = new SelectList(customerRoles, "Id", "Name", selectedId); ViewBag.AvailableVendors = new SelectList(vendors, "Id", "Name", selectedId); }
public ActionResult Delete(int id) { var role = new CustomerRoleDao().DeleteCustomerRole(id); return(RedirectToAction("Index")); }
public ActionResult Edit(int id) { var customer = new CustomerRoleDao().GetCustomerRoleById(id); return(View(customer)); }