public virtual IActionResult List() { if (!_permissionService.Authorize(StandardPermissionProvider.ManageCustomers) && !_permissionService.Authorize(ProgressivePermissionProvider.ProgressivePermissionRecord)) { return(AccessDeniedView()); } //load registered customers by default var defaultRoleIds = new List <int> { _customerService.GetCustomerRoleBySystemName(SystemCustomerRoleNames.Registered).Id }; var model = new OfferTypeModel { UsernamesEnabled = _customerSettings.UsernamesEnabled, DateOfBirthEnabled = _customerSettings.DateOfBirthEnabled, 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("~/Plugins/Progressive.Web.App/Views/SentOffer.cshtml", model)); }
public virtual IActionResult CustomerList(DataSourceRequest command, OfferTypeModel model, int[] searchCustomerRoleIds) { //we use own own binder for searchCustomerRoleIds property if (!_permissionService.Authorize(StandardPermissionProvider.ManageCustomers) && !_permissionService.Authorize(ProgressivePermissionProvider.ProgressivePermissionRecord)) { return(AccessDeniedKendoGridJson()); } var searchDayOfBirth = 0; var searchMonthOfBirth = 0; if (!string.IsNullOrWhiteSpace(model.SearchDayOfBirth)) { searchDayOfBirth = Convert.ToInt32(model.SearchDayOfBirth); } if (!string.IsNullOrWhiteSpace(model.SearchMonthOfBirth)) { searchMonthOfBirth = Convert.ToInt32(model.SearchMonthOfBirth); } var customers = _customerServiceExtend.GetAllCustomersExtend( customerRoleIds: searchCustomerRoleIds, email: model.SearchEmail, username: model.SearchUsername, dayOfBirth: searchDayOfBirth, monthOfBirth: searchMonthOfBirth, ipAddress: model.SearchIpAddress, loadOnlyWithShoppingCart: model.HasShoppingCart || model.HasWishList, sct: (model.HasShoppingCart && model.HasWishList) || (!model.HasShoppingCart && !model.HasWishList) ? (ShoppingCartType?)null : model.HasShoppingCart ? ShoppingCartType.ShoppingCart : ShoppingCartType.Wishlist, hasOfferInShoppingCartOrWishlist: model.HasOfferInShoppingCartOrWishlist, offerType: model.OfferType, offerId: model.OfferId, hasSubscription: model.HasSubscription, pageIndex: command.Page - 1, pageSize: command.PageSize); var gridModel = new DataSourceResult { Data = customers.Select(PrepareCustomerModelForList), Total = customers.TotalCount }; return(Json(gridModel)); }