public OrderActionListModel FindOrderActioning(int companyId, int locationId, int regionId, int nextActionId, int brandCategoryId, int index, int pageNo = 1, int pageSize = Int32.MaxValue, string search = "", string sortColumn = "", SortOrder sortOrder = SortOrder.Asc) { var model = new OrderActionListModel(); 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 => s.BrandCategoryId == brandCategoryId && s.LocationId == locationId && (regionId == 0 || s.Customer.RegionId == regionId) && (nextActionId == 0 || s.NextActionId == nextActionId) && s.SalesOrderHeaderStatu.Id == (int)SalesOrderHeaderStatus.ConfirmedOrder && s.NextActionId != (int)Enumerations.SaleNextAction.None && ((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 soh in allItems.Skip((pageNo - 1) * pageSize) .Take(pageSize)) { var item = new OrderActionItemModel { Id = soh.Id, NextActionText = (soh.SaleNextAction == null ? "" : soh.SaleNextAction.NextActionDescription), RegionName = soh.Customer.Region.RegionName, PostCode = soh.ShipPostcode, OrderNumber = soh.OrderNumber, OrderNumberUrl = $"<a href=\"/Sales/Sales/Edit?id={soh.Id}\">{soh.OrderNumber}</a>", CustPO = soh.CustPO, CustomerName = soh.Customer.Name, CustomerUrl = $"<a href=\"/Customers/Customers/Edit?id={soh.CustomerId}\">{soh.Customer.Name}</a>", WarehouseInstructions = soh.WarehouseInstructions, OrderDateISO = getFieldValueISODate(soh.OrderDate), DeliveryWindowOpenISO = getFieldValueISODate(soh.DeliveryWindowOpen), DeliveryWindowCloseISO = getFieldValueISODate(soh.DeliveryWindowClose), SalesPersonName = (soh.User_SalesPerson == null ? "" : (soh.User_SalesPerson.FirstName + " " + soh.User_SalesPerson.LastName).Trim()), FreightCarrier = (soh.FreightCarrier == null ? "" : soh.FreightCarrier.FreightCarrier1) }; model.Items.Add(item); } return(model); }
public void FindOrderActioningTest() { var testUser = GetTestUser(); var testCompany = GetTestCompany(testUser); var testCustomer = GetTestCustomer(testCompany, testUser); var brandCategory = ProductService.FindBrandCategoriesModel(testCompany).FirstOrDefault(); var additionalInfo = CustomerService.FindCustomerAdditionalInfoModel(testCustomer.Id, testCompany); OrderActionListModel orderList = SalesService.FindOrderActioning(testCompany.Id, testCompany.DefaultLocationID.Value, additionalInfo.RegionId.Value, 0, brandCategory.Id, 0); var expected = 0; var actual = orderList.Items.Count(); Assert.IsTrue(expected == actual, $"Error: {expected} numeber of records should exist in the db, when {actual} was found"); // Create an X amount of Sales List <SalesOrderHeaderModel> sohList = new List <SalesOrderHeaderModel>(); for (var i = 0; i <= RandomInt(5, 20); i++) { var soh = GetTestSalesOrderHeader(testCompany, testCustomer, testUser); var soStatus = LookupService.FindSalesOrderHeaderStatusByValueModel(SalesOrderHeaderStatus.ConfirmedOrder); soh.SOStatus = soStatus.Id; soh.SOStatusValue = (SalesOrderHeaderStatus)soStatus.StatusValue; soh.SOStatusText = soStatus.StatusName; soh.NextActionId = (int)Enumerations.SaleNextAction.AwaitingPaymentAccounts; var error = SalesService.InsertOrUpdateSalesOrderHeader(soh, testUser, SalesService.LockSalesOrderHeader(soh)); Assert.IsTrue(!error.IsError, error.Message); sohList.Add(soh); } expected = sohList.Count(); orderList = SalesService.FindOrderActioning(testCompany.Id, testCompany.DefaultLocationID.Value, 0, 0, brandCategory.Id, 0); actual = orderList.Items.Count(); Assert.IsTrue(expected == actual, $"Error: {expected} numeber of records should exist in the db, when {actual} was found"); // Delete them foreach (var order in sohList) { SalesService.DeleteSalesOrderHeader(order); } orderList = SalesService.FindOrderActioning(testCompany.Id, testCompany.DefaultLocationID.Value, 0, 0, brandCategory.Id, 0); expected = 0; actual = orderList.Items.Count(); Assert.IsTrue(expected == actual, $"Error: {expected} numeber of records should exist in the db, when {actual} was found"); }
/// <summary> /// 订单动作列表 /// </summary> public ActionResult OrderActionList() { int oid = WebHelper.GetQueryInt("oid"); OrderInfo orderInfo = Orders.GetOrderByOid(oid); if (orderInfo == null || orderInfo.Uid != WorkContext.Uid) { return(PromptView("订单不存在")); } OrderActionListModel model = new OrderActionListModel(); model.OrderInfo = orderInfo; model.OrderActionList = OrderActions.GetOrderActionList(oid); return(View(model)); }