public PagedResultDto <ProductListDto> GetPagedProduct(PageParams pageArg) { PageArgDto input = new PageArgDto(pageArg); bool isSearch = !string.IsNullOrEmpty(input.SearchText); IQueryable <Product> product = _productRepository.GetAll(); bool orderByDesc = input.SortOrder == "desc" ? true : false; string sortName = !string.IsNullOrEmpty(input.SortName) ? input.SortName.Substring(0, 1).ToUpper() + input.SortName.Substring(1) : "CreationTime"; //连表查询 var list = (from productItem in product join project in _projectRepository.GetAll() on productItem.ProjectId equals project.Id where (isSearch ? productItem.Name.Contains(input.SearchText) || project.Name.Contains(input.SearchText) : true) select new ProductListDto { Id = productItem.Id, Name = productItem.Name, ProjectName = project.Name, NameAlias = productItem.NameAlias, Category = productItem.Category, Description = productItem.Description, Stopped = productItem.Stopped, SalesUnit = productItem.SalesUnit, CreationTime = productItem.CreationTime }).OrderBy(sortName, orderByDesc); int count = list.Count(); var resultList = list.PageBy(input.PageInput).ToList(); return(new PagedResultDto <ProductListDto>(count, resultList)); }
/// <summary> /// 角色分页控制器服务/API接口 /// </summary> /// <param name="pageArg"></param> /// <returns></returns> public PagedResultDto <RoleListDto> GetPagedRole(PageParams pageArg) { PageArgDto input = new PageArgDto(pageArg); int count = 0; IQueryable <Role> roles = null; if (!string.IsNullOrEmpty(input.SearchText)) { roles = _roleRepository.GetAll().Where(m => m.Name.Contains(input.SearchText) || m.DisplayName.Contains(input.SearchText)); count = roles.Count(); } else { roles = _roleRepository.GetAll(); count = _roleRepository.Count(); } if (!string.IsNullOrEmpty(input.SortName)) { //将首字母转成大写 input.SortName = input.SortName.Substring(0, 1).ToUpper() + input.SortName.Substring(1); roles = input.SortOrder == "desc" ? roles.OrderBy(input.SortName, true).PageBy(input.PageInput) : roles.OrderBy(input.SortName).PageBy(input.PageInput); } else { //默认按时间降序 roles = roles.OrderByDescending(m => m.CreationTime).PageBy(input.PageInput); } return(new PagedResultDto <RoleListDto>(count, roles.MapTo <List <RoleListDto> >())); }
public PagedResultDto <SalesOrderListDto> GetPagedSalesOrder(PageParams pageArg) { PageArgDto input = new PageArgDto(pageArg); bool isSearch = !string.IsNullOrEmpty(input.SearchText); IQueryable <SalesOrder> salesOrder = _salesOrderRepository.GetAllIncluding(m => m.SalesOrderItem); bool orderByDesc = input.SortOrder == "desc" ? true : false; string sortName = !string.IsNullOrEmpty(input.SortName) ? input.SortName.Substring(0, 1).ToUpper() + input.SortName.Substring(1) : "CreationTime"; //连表查询 var list = (from order in salesOrder join client in _clientRepository.GetAll() on order.ClientId equals client.Id join contract in _contractRepository.GetAll() on order.SalesContractId equals contract.Id where (isSearch ? order.SalesNum.Contains(input.SearchText) || client.Name.Contains(input.SearchText) : true) select new SalesOrderListDto { Id = order.Id, SalesNum = order.SalesNum, ClientName = client.Name, ContractNum = contract.ContractNum, CreationTime = order.CreationTime }).OrderBy(sortName, orderByDesc); int count = list.Count(); var resultList = list.PageBy(input.PageInput).ToList(); //附表数据映射 foreach (var item in resultList) { item.SalesOrderItems = salesOrder.Where(m => m.Id == item.Id).FirstOrDefault().SalesOrderItem.MapTo <List <SalesOrderItemListDto> >(); } return(new PagedResultDto <SalesOrderListDto>(count, resultList)); }
/// <summary> /// 角色分页控制器服务/API接口 /// </summary> /// <param name="pageArg"></param> /// <returns></returns> public PagedResultDto <UserListDto> GetPagedUser(PageParams pageArg) { PageArgDto input = new PageArgDto(pageArg); int count = 0; IQueryable <User> users = null; if (!string.IsNullOrEmpty(input.SearchText)) { users = _userRepository.GetAll().Where(m => m.FullName.Contains(input.SearchText) || m.UserName.Contains(input.SearchText) || m.EmailAddress.Contains(input.SearchText)); count = users.Count(); } else { users = _userRepository.GetAll(); count = _userRepository.Count(); } if (!string.IsNullOrEmpty(input.SortName)) { //将首字母转成大写 input.SortName = input.SortName.Substring(0, 1).ToUpper() + input.SortName.Substring(1); users = input.SortOrder == "desc" ? users.OrderBy(input.SortName, true).PageBy(input.PageInput) : users.OrderBy(input.SortName).PageBy(input.PageInput); } else { //默认按时间降序 users = users.OrderByDescending(m => m.CreationTime).PageBy(input.PageInput); } return(new PagedResultDto <UserListDto>(count, users.MapTo <List <UserListDto> >())); }
public PagedResultDto <ClientPaymentDto> GetPagedClientPayment(PageParams pageArg) { PageArgDto input = new PageArgDto(pageArg); bool isSearch = !string.IsNullOrEmpty(input.SearchText); IQueryable <ClientPayment> clientPayment = _clientPaymentRepository.GetAll(); bool orderByDesc = input.SortOrder == "desc" ? true : false; string sortName = !string.IsNullOrEmpty(input.SortName) ? input.SortName.Substring(0, 1).ToUpper() + input.SortName.Substring(1) : "CreationTime"; //连表查询 var list = (from clientPaymentItem in clientPayment join salesOrder in _salesOrderRepository.GetAll() on clientPaymentItem.SalesOrderId equals salesOrder.Id join client in _clientRepository.GetAll() on salesOrder.ClientId equals client.Id join userInfo in _userRepository.GetAll() on clientPaymentItem.CreatorUserId equals userInfo.Id where (isSearch ? salesOrder.SalesNum.Contains(input.SearchText) || client.Name.Contains(input.SearchText) : true) select new ClientPaymentDto { Id = clientPaymentItem.Id, SalesOrderId = clientPaymentItem.SalesOrderId, SalesOrderNum = salesOrder.SalesNum, ClientName = client.Name, PaymentBank = clientPaymentItem.PaymentBank, BankTransactionNum = clientPaymentItem.BankTransactionNum, PaymentSum = clientPaymentItem.PaymentSum, ReceiptBank = clientPaymentItem.ReceiptBank, ReceiptAccountId = clientPaymentItem.ReceiptAccountId, State = clientPaymentItem.State, CreatorUserName = userInfo.UserName, CreationTime = clientPaymentItem.CreationTime }).OrderBy(sortName, orderByDesc); int count = list.Count(); var resultList = list.PageBy(input.PageInput).ToList(); return(new PagedResultDto <ClientPaymentDto>(count, resultList)); }
public PagedResultDto <ReceiptListDto> GetPagedReceipt(PageParams pageArg) { PageArgDto input = new PageArgDto(pageArg); bool isSearch = !string.IsNullOrEmpty(input.SearchText); IQueryable <Receipt> receipt = _receiptRepository.GetAll(); bool orderByDesc = input.SortOrder == "desc" ? true : false; string sortName = !string.IsNullOrEmpty(input.SortName) ? input.SortName.Substring(0, 1).ToUpper() + input.SortName.Substring(1) : "CreationTime"; //连表查询 var list = (from receiptItem in receipt join client in _clientRepository.GetAll() on receiptItem.ClientId equals client.Id where (isSearch ? client.Name.Contains(input.SearchText) : true) select new ReceiptListDto { Id = receiptItem.Id, ClientName = client.Name, JournalBalance = receiptItem.JournalBalance, JournalName = receiptItem.JournalName, State = receiptItem.State, ReceiptDate = receiptItem.ReceiptDate, CreationTime = receiptItem.CreationTime }).OrderBy(sortName, orderByDesc); int count = list.Count(); var resultList = list.PageBy(input.PageInput).ToList(); return(new PagedResultDto <ReceiptListDto>(count, resultList)); }
public PagedResultDto <SupplierListDto> GetPagedSupplier(PageParams pageArg) { PageArgDto input = new PageArgDto(pageArg); bool isSearch = !string.IsNullOrEmpty(input.SearchText); IQueryable <Supplier> supplier = _supplierRepository.GetAll(); bool orderByDesc = input.SortOrder == "desc" ? true : false; string sortName = !string.IsNullOrEmpty(input.SortName) ? input.SortName.Substring(0, 1).ToUpper() + input.SortName.Substring(1) : "CreationTime"; //连表查询 var list = (from supplierItem in supplier where (isSearch ? supplierItem.Name.Contains(input.SearchText) || supplierItem.NameAlias.Contains(input.SearchText) : true) select supplierItem).OrderBy(sortName, orderByDesc); int count = list.Count(); var resultList = list.PageBy(input.PageInput).ToList().MapTo <List <SupplierListDto> >(); return(new PagedResultDto <SupplierListDto>(count, resultList)); }
public PagedResultDto <ProjectListDto> GetPagedProject(PageParams pageArg) { PageArgDto input = new PageArgDto(pageArg); bool isSearch = !string.IsNullOrEmpty(input.SearchText); IQueryable <Project> project = _projectRepository.GetAll(); bool orderByDesc = input.SortOrder == "desc" ? true : false; string sortName = !string.IsNullOrEmpty(input.SortName) ? input.SortName.Substring(0, 1).ToUpper() + input.SortName.Substring(1) : "CreationTime"; //连表查询 var list = (from projectItem in project where (isSearch ? projectItem.Name.Contains(input.SearchText) || projectItem.Description.Contains(input.SearchText) : true) select projectItem).OrderBy(sortName, orderByDesc); int count = list.Count(); var resultList = list.PageBy(input.PageInput).ToList(); return(new PagedResultDto <ProjectListDto>(count, resultList.MapTo <List <ProjectListDto> >())); }
public PagedResultDto <DeliverListDto> GetPagedDeliver(PageParams pageArg) { PageArgDto input = new PageArgDto(pageArg); bool isSearch = !string.IsNullOrEmpty(input.SearchText); IQueryable <Deliver> deliver = _deliverRepository.GetAll(); bool orderByDesc = input.SortOrder == "desc" ? true : false; string sortName = !string.IsNullOrEmpty(input.SortName) ? input.SortName.Substring(0, 1).ToUpper() + input.SortName.Substring(1) : "DeliverTime"; //连表查询 var list = (from deliverItem in deliver join salesOrder in _salesOrderRepository.GetAll() on deliverItem.SalesOrderId equals salesOrder.Id where (isSearch ? deliverItem.LogisticsNum.Contains(input.SearchText) || salesOrder.SalesNum.Contains(input.SearchText) : true) select new DeliverListDto { Id = deliverItem.Id, SalesOrderNum = salesOrder.SalesNum, LogisticsCompany = deliverItem.LogisticsCompany, LogisticsNum = deliverItem.LogisticsNum, DeliverTime = deliverItem.DeliverTime }).OrderBy(sortName, orderByDesc); int count = list.Count(); var resultList = list.PageBy(input.PageInput).ToList(); return(new PagedResultDto <DeliverListDto>(count, resultList)); }