コード例 #1
0
        /// <summary>
        /// Update routing info provided by customer
        /// </summary>
        /// <param name="updater"></param>
        /// <returns></returns>
        internal int UpdateRouting(RoutingUpdater updater)
        {
            int count = 0;
            // Since counts for this customer have changed, remove them from the cache
            var cache = CustomerOrderSummaryCache;

            foreach (var customerId in updater.RoutingKeys.Select(p => p.CustomerId).Distinct())
            {
                cache.Remove(customerId);
            }
            // If null value is provided for DC or Carrier, update them with original values for each selected PO.
            if (updater.UpdateCustomerDcId == true && string.IsNullOrEmpty(updater.CustomerDcId) || updater.UpdateCarrierId == true && string.IsNullOrEmpty(updater.CarrierId))
            {
                foreach (var item in updater.RoutingKeys)
                {
                    var newupdater = new RoutingUpdater
                    {
                        RoutingKeys        = updater.RoutingKeys.Where(p => p.Key == item.Key).ToArray(),
                        CustomerDcId       = updater.CustomerDcId,
                        UpdateCustomerDcId = updater.UpdateCustomerDcId,
                        PickUpDate         = updater.PickUpDate,
                        UpdatePickupDate   = updater.UpdatePickupDate,
                        LoadId             = updater.LoadId,
                        UpdateLoadId       = updater.UpdateLoadId,
                        CarrierId          = updater.CarrierId,
                        UpdateCarrierId    = updater.UpdateCarrierId
                    };
                    var defaultRoutinginfo = _repos.GetDefaultRoutingInfo(item.CustomerId, item.PoId, item.Iteration, item.DcId);
                    if (updater.UpdateCustomerDcId == true && string.IsNullOrEmpty(updater.CustomerDcId))
                    {
                        newupdater.CustomerDcId = defaultRoutinginfo.Item1;
                    }
                    if (updater.UpdateCarrierId == true && string.IsNullOrEmpty(updater.CarrierId))
                    {
                        newupdater.CarrierId = defaultRoutinginfo.Item2;
                    }
                    count += _repos.UpdateRouting(newupdater);
                }
            }
            else
            {
                count = _repos.UpdateRouting(updater);
            }
            return(count);
        }