public ActionResult List() { if (!_permissionService.Authorize(StandardPermissionProvider.ManageCustomers)) return AccessDeniedView(); //load registered customers by default var defaultRoleIds = new[] { _customerService.GetCustomerRoleBySystemName(SystemCustomerRoleNames.Registered).Id }; var model = new CustomerListModel { UsernamesEnabled = _customerSettings.UsernamesEnabled, DateOfBirthEnabled = _customerSettings.DateOfBirthEnabled, CompanyEnabled = _customerSettings.CompanyEnabled, PhoneEnabled = _customerSettings.PhoneEnabled, ZipPostalCodeEnabled = _customerSettings.ZipPostalCodeEnabled, AvailableCustomerRoles = _customerService.GetAllCustomerRoles(true).Select(cr => cr.ToModel()).ToList(), SearchCustomerRoleIds = defaultRoleIds, }; return View(model); }
public ActionResult CustomerList(DataSourceRequest command, CustomerListModel model, [ModelBinder(typeof(CommaSeparatedModelBinder))] int[] searchCustomerRoleIds) { //we use own own binder for searchCustomerRoleIds property if (!_permissionService.Authorize(StandardPermissionProvider.ManageCustomers)) return AccessDeniedView(); var searchDayOfBirth = 0; int searchMonthOfBirth = 0; if (!String.IsNullOrWhiteSpace(model.SearchDayOfBirth)) searchDayOfBirth = Convert.ToInt32(model.SearchDayOfBirth); if (!String.IsNullOrWhiteSpace(model.SearchMonthOfBirth)) searchMonthOfBirth = Convert.ToInt32(model.SearchMonthOfBirth); var customers = _customerService.GetAllCustomers( email: model.SearchEmail, username: model.SearchUsername, pageIndex: command.Page - 1, pageSize: command.PageSize); var gridModel = new DataSourceResult { Data = customers.Select(PrepareCustomerModelForList), Total = customers.TotalCount }; return Json(gridModel); }