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) { var model = new GridModel <AffiliateModel.AffiliatedCustomerModel>(); if (_permissionService.Authorize(StandardPermissionProvider.ManageAffiliates)) { var affiliate = _affiliateService.GetAffiliateById(affiliateId); var customers = _customerService.GetAllCustomers(affiliate.Id, command.Page - 1, command.PageSize); model.Data = customers.Select(customer => { var customerModel = new AffiliateModel.AffiliatedCustomerModel { Id = customer.Id, Email = customer.Email, Username = customer.Username, FullName = customer.GetFullName() }; return(customerModel); }); model.Total = customers.TotalCount; } else { model.Data = Enumerable.Empty <AffiliateModel.AffiliatedCustomerModel>(); NotifyAccessDenied(); } return(new JsonResult { Data = model }); }
public ActionResult AffiliatedCustomerList(int affiliateId, GridCommand command) { var model = new GridModel <AffiliateModel.AffiliatedCustomerModel>(); var q = new CustomerSearchQuery { AffiliateId = affiliateId, PageIndex = command.Page - 1, PageSize = command.PageSize }; var customers = _customerService.SearchCustomers(q); model.Data = customers.Select(customer => { var customerModel = new AffiliateModel.AffiliatedCustomerModel { Id = customer.Id, Email = customer.Email, Username = customer.Username, FullName = customer.GetFullName() }; return(customerModel); }); model.Total = customers.TotalCount; return(new JsonResult { Data = model }); }
public virtual (IEnumerable <AffiliateModel.AffiliatedCustomerModel> affiliateCustomerModels, int totalCount) PrepareAffiliatedCustomerList(Affiliate affiliate, int pageIndex, int pageSize) { var customers = _customerService.GetAllCustomers( affiliateId: affiliate.Id, pageIndex: pageIndex - 1, pageSize: pageSize); return(customers.Select(customer => { var customerModel = new AffiliateModel.AffiliatedCustomerModel(); customerModel.Id = customer.Id; customerModel.Name = customer.Email; return customerModel; }), customers.TotalCount); }
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 customers = _customerService.GetAllCustomers( affiliateId: affiliate.Id, pageIndex: command.Page - 1, pageSize: command.PageSize); 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 }); }
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 = _customerService.GetAllCustomers(affiliate.Id, command.Page - 1, command.PageSize); var model = new GridModel <AffiliateModel.AffiliatedCustomerModel> { Data = customers.Select(customer => { var customerModel = new AffiliateModel.AffiliatedCustomerModel() { Id = customer.Id, Email = customer.Email, Username = customer.Username, FullName = customer.GetFullName() }; return(customerModel); }), Total = customers.TotalCount }; return(new JsonResult { Data = model }); }