public ActionResult AffiliatedCustomerList(int affiliateId, DataSourceRequest command) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageAffiliates)) return AccessDeniedView(); var affiliate = _affiliateService.GetAffiliateById(affiliateId); if (affiliate == null) throw new ArgumentException("No affiliate found with the specified id"); var customers = _customerService.GetAllCustomers( affiliateId: affiliate.Id, pageIndex: command.Page - 1, pageSize: command.PageSize); var gridModel = new DataSourceResult { Data = customers.Select(customer => { var customerModel = new AffiliateModel.AffiliatedCustomerModel(); customerModel.Id = customer.Id; customerModel.Name = customer.Email; return customerModel; }), Total = customers.TotalCount }; return Json(gridModel); }
public ActionResult AffiliatedCustomerList(int affiliateId, GridCommand command) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageAffiliates)) return AccessDeniedView(); var affiliate = _affiliateService.GetAffiliateById(affiliateId); if (affiliate == null) throw new ArgumentException("No affiliate found with the specified id"); var customers = affiliate.AffiliatedCustomers .Where(c => !c.Deleted) .OrderBy(x => x.CreatedOnUtc) .ToList(); var model = new GridModel<AffiliateModel.AffiliatedCustomerModel> { Data = customers.PagedForCommand(command) .Select(customer => { var customerModel = new AffiliateModel.AffiliatedCustomerModel(); customerModel.Id = customer.Id; customerModel.Name = customer.GetFullName(); return customerModel; }), Total = customers.Count }; return new JsonResult { Data = model }; }