public SalesOrderHeaderListModel FindSalesOrderHeaderSummaryListModel(CompanyModel company, UserModel user, int index, int pageNo, int pageSize, string search) { // This is the similar to FindSalesOrderHeadersListModel above except that it // only shows active sales for the parameter user instead of all sales for all users var model = new SalesOrderHeaderListModel(); int searchInt = -1; int.TryParse(search, out searchInt); // Do a case-insensitive search model.GridIndex = index; var allItems = db.FindSalesOrderHeaders(company.Id) .Where(s => s.SalesOrderHeaderStatu.StatusValue != (int)SalesOrderHeaderStatus.Cancelled && s.SalespersonId == user.Id && ((string.IsNullOrEmpty(search) || (s.Customer != null && (s.Customer.Name.Contains(search))) || (s.CustPO != null && (s.CustPO.Contains(search))) || (s.User_SalesPerson != null && ((s.User_SalesPerson.FirstName + " " + s.User_SalesPerson.LastName).Trim().Contains(search))) ) || (searchInt == -1 || s.OrderNumber == searchInt))); model.TotalRecords = allItems.Count(); foreach (var item in allItems.Skip((pageNo - 1) * pageSize) .Take(pageSize)) { var newItem = MapToModel(item); model.Items.Add(newItem); } return(model); }
public SalesOrderHeaderListModel FindSalesOrderHeadersListModel(int companyId, int index, int pageNo, int pageSize, string search, int salesPersonId, int regionId, int countryId, int locationId, int soStatusId, int brandCategoryId, string sortColumn = "", SortOrder sortOrder = SortOrder.Asc) { var model = new SalesOrderHeaderListModel(); int searchInt = -1; int.TryParse(search, out searchInt); // Do a case-insensitive search model.GridIndex = index; var allItems = db.FindSalesOrderHeaders(companyId, sortColumn, sortOrder) .Where(s => (salesPersonId == 0 || s.SalespersonId == salesPersonId) && (regionId == 0 || s.Customer.RegionId == regionId) && (countryId == 0 || s.ShipCountryId == countryId) && (locationId == 0 || s.LocationId == locationId) && (soStatusId == 0 || s.SOStatus == soStatusId) && (brandCategoryId == 0 || s.BrandCategoryId == brandCategoryId) && ((string.IsNullOrEmpty(search) || (s.Customer != null && (s.Customer.Name.Contains(search))) || (s.CustPO != null && (s.CustPO.Contains(search))) || (s.User_SalesPerson != null && ((s.User_SalesPerson.FirstName + " " + s.User_SalesPerson.LastName).Trim().Contains(search))) ) || (searchInt == -1 || s.OrderNumber == searchInt))); model.TotalRecords = allItems.Count(); foreach (var item in allItems.Skip((pageNo - 1) * pageSize) .Take(pageSize)) { model.Items.Add(MapToModel(item)); } return(model); }
public SalesOrderHeaderListModel FindCreditCardSales(CompanyModel company, int cardId) { var model = new SalesOrderHeaderListModel(); foreach (var item in db.FindSalesOrderHeaders(company.Id) .Where(soh => soh.CreditCardId == cardId)) { model.Items.Add(MapToModel(item)); } return(model); }