public ActionResult List() { if (!_permissionService.Authorize(StandardPermissionProvider.ManageCustomers)) return AccessDeniedView(); //load registered customers by default var defaultRoleIds = new[] {_customerService.GetCustomerRoleBySystemName(SystemCustomerRoleNames.Registered).Id}; var listModel = 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(listModel); }
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( customerRoleIds: searchCustomerRoleIds, email: model.SearchEmail, username: model.SearchUsername, firstName: model.SearchFirstName, lastName: model.SearchLastName, dayOfBirth: searchDayOfBirth, monthOfBirth: searchMonthOfBirth, company: model.SearchCompany, phone: model.SearchPhone, zipPostalCode: model.SearchZipPostalCode, loadOnlyWithShoppingCart: false, pageIndex: command.Page - 1, pageSize: command.PageSize); var gridModel = new DataSourceResult { Data = customers.Select(PrepareCustomerModelForList), Total = customers.TotalCount }; return Json(gridModel); }
public ActionResult ExportXmlAll(CustomerListModel model) { 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( customerRoleIds: model.SearchCustomerRoleIds.ToArray(), email: model.SearchEmail, username: model.SearchUsername, firstName: model.SearchFirstName, lastName: model.SearchLastName, dayOfBirth: searchDayOfBirth, monthOfBirth: searchMonthOfBirth, company: model.SearchCompany, phone: model.SearchPhone, zipPostalCode: model.SearchZipPostalCode, loadOnlyWithShoppingCart: false); try { var xml = _exportManager.ExportCustomersToXml(customers); return new XmlDownloadResult(xml, "customers.xml"); } catch (Exception exc) { ErrorNotification(exc); return RedirectToAction("List"); } }
public ActionResult List() { if (!_permissionService.Authorize(StandardPermissionProvider.ManageCustomers)) return AccessDeniedView(); //load registered customers by default var defaultRoleIds = new List<int> {_customerService.GetCustomerRoleBySystemName(SystemCustomerRoleNames.Registered).Id}; var model = new CustomerListModel { UsernamesEnabled = _customerSettings.UsernamesEnabled, DateOfBirthEnabled = _customerSettings.DateOfBirthEnabled, CompanyEnabled = _customerSettings.CompanyEnabled, PhoneEnabled = _customerSettings.PhoneEnabled, ZipPostalCodeEnabled = _customerSettings.ZipPostalCodeEnabled, SearchCustomerRoleIds = defaultRoleIds, }; var allRoles = _customerService.GetAllCustomerRoles(true); foreach (var role in allRoles) { model.AvailableCustomerRoles.Add(new SelectListItem { Text = role.Name, Value = role.Id.ToString(), Selected = defaultRoleIds.Any(x => x == role.Id) }); } return View(model); }
public ActionResult ExportExcelAll(CustomerListModel model) { 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( customerRoleIds: model.SearchCustomerRoleIds, email: model.SearchEmail, username: model.SearchUsername, firstName: model.SearchFirstName, lastName: model.SearchLastName, dayOfBirth: searchDayOfBirth, monthOfBirth: searchMonthOfBirth, company: model.SearchCompany, phone: model.SearchPhone, zipPostalCode: model.SearchZipPostalCode, loadOnlyWithShoppingCart: false); try { byte[] bytes; using (var stream = new MemoryStream()) { _exportManager.ExportCustomersToXlsx(stream, customers); bytes = stream.ToArray(); } return File(bytes, "text/xls", "customers.xlsx"); } catch (Exception exc) { ErrorNotification(exc); return RedirectToAction("List"); } }
public ActionResult List() { if (!_permissionService.Authorize(StandardPermissionProvider.ManageCustomers)) return AccessDeniedView(); //load registered customers by default var defaultRoleIds = new[] {_customerService.GetCustomerRoleBySystemName(SystemCustomerRoleNames.Registered).Id}; var listModel = 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, }; var customers = _customerService.GetAllCustomers( customerRoleIds: defaultRoleIds, pageIndex: 0, pageSize: _adminAreaSettings.GridPageSize); //customer list listModel.Customers = new GridModel<CustomerModel> { Data = customers.Select(PrepareCustomerModelForList), Total = customers.TotalCount }; return View(listModel); }
public ActionResult CustomerList(GridCommand command, CustomerListModel model, [ModelBinderAttribute(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(null, null, searchCustomerRoleIds, model.SearchEmail, model.SearchUsername, model.SearchFirstName, model.SearchLastName, searchDayOfBirth, searchMonthOfBirth, model.SearchCompany, model.SearchPhone, model.SearchZipPostalCode, false, null, command.Page - 1, command.PageSize); var gridModel = new GridModel<CustomerModel> { Data = customers.Select(PrepareCustomerModelForList), Total = customers.TotalCount }; return new JsonResult { Data = gridModel }; }
public ActionResult List() { if (!_permissionService.Authorize(StandardPermissionProvider.ManageCustomers)) return AccessDeniedView(); //load registered customers by default var defaultRoleIds = new int[] { _customerService.GetCustomerRoleBySystemName(SystemCustomerRoleNames.Registered).Id }; //convert to string because passing int[] to grid is no possible string searchCustomerRoleIdsStr = ""; foreach (var i in defaultRoleIds) searchCustomerRoleIdsStr += i + ","; ViewData["searchCustomerRoleIds"] = searchCustomerRoleIdsStr; var listModel = new CustomerListModel() { UsernamesEnabled = _customerSettings.UsernamesEnabled, DateOfBirthEnabled = _customerSettings.DateOfBirthEnabled, AvailableCustomerRoles = _customerService.GetAllCustomerRoles(true).ToList(), SearchCustomerRoleIds = defaultRoleIds, }; var customers = _customerService.GetAllCustomers(null, null, defaultRoleIds, null, null, null, null, 0, 0, false, null, 0, _adminAreaSettings.GridPageSize); //customer list listModel.Customers = new GridModel<CustomerModel> { Data = customers.Select(x => PrepareCustomerModelForList(x)), Total = customers.TotalCount }; return View(listModel); }
public ActionResult Search(CustomerListModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageCustomers)) return AccessDeniedView(); model.UsernamesEnabled = _customerSettings.UsernamesEnabled; model.DateOfBirthEnabled = _customerSettings.DateOfBirthEnabled; //convert to string because passing int[] to grid is no possible string searchCustomerRoleIdsStr = ""; if (model.SearchCustomerRoleIds != null) foreach (var i in model.SearchCustomerRoleIds) searchCustomerRoleIdsStr+= i + ","; ViewData["searchCustomerRoleIds"] = searchCustomerRoleIdsStr; //if (model.SearchCustomerRoleIds != null) //List<int> converter should be registered //ViewData["searchCustomerRoleIds"] = CommonHelper.GetNopCustomTypeConverter(typeof(List<int>)).ConvertTo(model.SearchCustomerRoleIds, typeof(string)) as string; ViewData["searchCustomerEmail"] = model.SearchEmail; ViewData["searchCustomerUsername"] = model.SearchUsername; ViewData["searchCustomerFirstName"] = model.SearchFirstName; ViewData["searchCustomerLastName"] = model.SearchLastName; ViewData["searchCustomerDayOfBirth"] = model.SearchDayOfBirth; ViewData["searchCustomerMonthOfBirth"] = model.SearchMonthOfBirth; //customer roles var customerRoles = _customerService.GetAllCustomerRoles(true); model.AvailableCustomerRoles = customerRoles.ToList(); //date of birth int searchCustomerDayOfBirth = 0, searchCustomerMonthOfBirth = 0; if (!String.IsNullOrEmpty(model.SearchDayOfBirth)) searchCustomerDayOfBirth = Convert.ToInt32(model.SearchDayOfBirth); if (!String.IsNullOrEmpty(model.SearchMonthOfBirth)) searchCustomerMonthOfBirth = Convert.ToInt32(model.SearchMonthOfBirth); //load customers var customers = _customerService.GetAllCustomers(null, null, model.SearchCustomerRoleIds, model.SearchEmail, model.SearchUsername, model.SearchFirstName, model.SearchLastName, searchCustomerDayOfBirth, searchCustomerMonthOfBirth, false, null, 0, _adminAreaSettings.GridPageSize); //customer list model.Customers = new GridModel<CustomerModel> { Data = customers.Select(x => PrepareCustomerModelForList(x)), Total = customers.TotalCount }; return View(model); }