public IEnumerable <Models.Order> GetDeliveryOrders([FromRoute] string routeCode) { // Build new route helper Helpers.Route routeHelper = new Helpers.Route(_context); // Get orders list to be delivered today List <Models.Order> orders = routeHelper.GetRouteOrders(routeCode); // Verify whether orders list is not empty if (orders.Any()) { // Iterate through all orders found foreach (var order in orders) { // Find container return by order number var containerReturn = _context .ContainerReturns .Include(x => x.Items) .Where(x => x.ReturnNumber == order.OrderNumber) .FirstOrDefault(); // Verify whether container return is not null if (containerReturn != null) { // Assign container return found order.Container = containerReturn; } } } // Return result return(orders); }
public Models.Route GetRoute([FromRoute] string routeCode) { // Build new route helper Helpers.Route routeHelper = new Helpers.Route(_context); // Return result return(routeHelper.GetRoute(routeCode)); }
private void UpdateUserSettingWithLastConsecutiveNumbers(Models.User user) { // Get user setting var setting = user.Setting; // Verify whether user setting is not null if (setting != null) { // Get route code from user setting string routeCode = setting.Route; // Verify emptiness of route code if (!string.IsNullOrEmpty(routeCode)) { // Create a new route helper instance Helpers.Route routeHelper = new Helpers.Route(_context); // Get route detail Models.Route route = routeHelper.GetRoute(routeCode); // Verify whether route is not from presale if (route.RouteType.ToUpper() != Constants.PRESALE) { // Get consecutive invoices from route List <ConsecutiveInvoice> consecutiveInvoices = _context .ConsecutiveInvoices .Where(x => x.Route == routeCode) .ToList(); // Verify whether consecutive invoices list is not empty if (consecutiveInvoices.Any()) { // Get last invoice consecutive number int lastInvoiceNumber = consecutiveInvoices .Where(x => x.DocumentTypeId == "1") .Select(x => x.SequenceNumber) .First(); // Get last payment consecutive number int lastPaymentNumber = consecutiveInvoices .Where(x => x.DocumentTypeId == "2") .Select(x => x.SequenceNumber) .First(); // Assing values found to user setting setting.LastInvoiceNumber = lastInvoiceNumber; setting.LastPaymentNumber = lastPaymentNumber; } } } } }
private Boolean IsPresaleRoute(string routeCode) { // Create a new route helper instance Helpers.Route routeHelper = new Helpers.Route(_context); // Save route type var isPresaleRoute = false; // Get route detail Models.Route route = routeHelper.GetRoute(routeCode); // Verify whether the route found is empty or not if (route != null) { // Verify if route is for delivery or not isPresaleRoute = route.RouteType.ToUpper() == Constants.PRESALE; } return(isPresaleRoute); }
private Boolean IsDeliveryRoute(string routeCode) { // Create a new route helper instance Helpers.Route routeHelper = new Helpers.Route(_distributionContext); // Save route type var isDeliveryRoute = true; // Get route detail Models.Route route = routeHelper.GetRoute(routeCode); // Verify whether the route found is empty or not if (route != null) { // Verify if route is for delivery or not isDeliveryRoute = route.RouteType.ToUpper() == Constants.DELIVERY; } return(isDeliveryRoute); }
public List <Models.AS400.Customer> GetCustomersByRoute( [FromRoute] string routeCode, [FromRoute] Decimal?customerCode = null ) { // Create a new route helper instance Helpers.Route routeHelper = new Helpers.Route(_distributionContext); // Save route type var isDeliveryRoute = IsDeliveryRoute(routeCode); // Build query standard parameters List <QueryParameter> parameters = new List <QueryParameter>(); parameters.Add(new QueryParameter { key = "{schema}", value = AS400Schema.GetSchema(Constants.DATA_WAREHOUSE_PREFIX) }); parameters.Add(new QueryParameter { key = "{routeCodes}", value = $"'{routeCode}'" }); // Query all customers List <Models.AS400.Customer> customers = _BPCSContext .Customers .FromSql(QueryBuilder.Build("GetCustomersByRoute.txt", parameters)) .ToListAsync() .Result; // Verify whether customer code is not empty if (customerCode != null) { // Filter customer list by customer code customers = customers.FindAll(x => x.CustomerCode == customerCode); } // Verify whether route is for delivery or not if (isDeliveryRoute) { // Query orders and extract customer codes List <Models.Order> orders = routeHelper.GetRouteOrders(routeCode); // Verify whether any order was found if (orders.Count > 0) { // Create an empty list to store the customer codes List <int> customerCodes = new List <int>(); // Iterate through all orders found foreach (var order in orders) { // Verify whether the customer codes list do not contain the same customer code if (!customerCodes.Contains(Int32.Parse(order.CustomerCode))) { customerCodes.Add(Int32.Parse(order.CustomerCode)); } } // Verify whether the customer codes list is not empty if (customerCodes.Count > 0) { // Filter customers list by customer codes return(customers .FindAll(x => customerCodes.Contains(x.CustomerCode) || x.CreditLimit > 0)); } } else { return(new List <Models.AS400.Customer>()); } } // Return result return(customers); }
public List <PriceList> GetPriceListByRoute([FromRoute] string routeCode, [FromQuery] int numberOfRecords = 10) { // Create a new route helper instance Helpers.Route routeHelper = new Helpers.Route(_distributionContext); // Save route type var isDeliveryRoute = IsDeliveryRoute(routeCode); // Build query standard parameters List <QueryParameter> parameters = new List <QueryParameter>(); parameters.Add(new QueryParameter { key = "{numberOfRecords}", value = numberOfRecords.ToString() }); parameters.Add(new QueryParameter { key = "{schema}", value = AS400Schema.GetSchema(Constants.AS400_PREFIX) }); parameters.Add(new QueryParameter { key = "{routeCode}", value = routeCode }); // Query all price lists var priceLists = _BPCSContext .PriceLists .FromSql(QueryBuilder.Build("GetPriceListByRoute.txt", parameters)) .ToListAsync() .Result; // Verify whether route is for delivery or not if (isDeliveryRoute) { // Query orders and extract customer codes List <Models.Order> orders = routeHelper.GetRouteOrders(routeCode); // Verify whether any order was found if (orders.Count > 0) { // Create an empty list to store the item codes List <string> itemCodes = new List <string>(); // Iterate through all orders found foreach (var order in orders) { // Get order items List <OrderItem> items = order.Items; // Verify whether any item was found in the order if (items.Count > 0) { // Iterate through all items found foreach (var item in items) { // Verify whether the item codes list do not contain the same item code if (!itemCodes.Contains(item.ItemCode)) { itemCodes.Add(item.ItemCode); } } } } // Verify whether the item codes list is not empty if (itemCodes.Count > 0) { // Filter price lists by item codes return(priceLists.FindAll(x => itemCodes.Contains(x.ItemCode))); } } else { return(new List <PriceList>()); } } return(priceLists); }