コード例 #1
0
        public void Execute(Order entity)
        {
            if (entity.ShippingId.HasValue)
            {
                var entityShippingId = entity.ShippingId.Value;

                var shipping = _dataService.GetById <Shipping>(entityShippingId);

                var orders = _dataService.GetDbSet <Order>()
                             .Where(x => x.ShippingId == entityShippingId);

                foreach (var orderInShipping in orders)
                {
                    if (orderInShipping.TarifficationType != entity.TarifficationType)
                    {
                        _historyService.Save(orderInShipping.Id, "fieldChangedBy",
                                             nameof(entity.TarifficationType).ToLowerFirstLetter(),
                                             orderInShipping.TarifficationType, entity.TarifficationType, "onChangeInOtherOrderInShipping");

                        orderInShipping.TarifficationType = entity.TarifficationType;
                    }
                }

                if (shipping.TarifficationType != entity.TarifficationType)
                {
                    _historyService.Save(shipping.Id, "fieldChangedBy",
                                         nameof(shipping.TarifficationType).ToLowerFirstLetter(),
                                         shipping.TarifficationType, entity.TarifficationType, "onChangeInIncludedOrder");

                    shipping.TarifficationType = entity.TarifficationType;

                    _calcService.UpdateDeliveryCost(shipping);
                }
            }
        }
コード例 #2
0
        public void Execute(Shipping entity)
        {
            var orders = _dataService.GetDbSet <Order>()
                         .Where(x => x.ShippingId == entity.Id);

            var transportCompanies = _dataService.GetDbSet <TransportCompany>();

            foreach (var orderInShipping in orders)
            {
                if (orderInShipping.CarrierId != entity.CarrierId)
                {
                    TransportCompany oldCarrier = null;
                    TransportCompany newCarrier = null;

                    if (orderInShipping.CarrierId.HasValue)
                    {
                        oldCarrier = transportCompanies.GetById(orderInShipping.VehicleTypeId.GetValueOrDefault());
                    }

                    if (entity.VehicleTypeId.HasValue)
                    {
                        newCarrier = transportCompanies.GetById(entity.VehicleTypeId.GetValueOrDefault());
                    }

                    orderInShipping.CarrierId = entity.CarrierId;

                    _historyService.Save(orderInShipping.Id, "fieldChangedBy",
                                         nameof(orderInShipping.VehicleTypeId).ToLowerFirstLetter(),
                                         oldCarrier, newCarrier, "onChangeInShipping");
                }
                _calcService.UpdateDeliveryCost(entity);
            }
        }
コード例 #3
0
        public void Execute(Shipping entity)
        {
            var orders = _dataService.GetDbSet <Order>()
                         .Where(x => x.ShippingId == entity.Id);

            var vehicleTypes = _dataService.GetDbSet <VehicleType>();

            foreach (var orderInShipping in orders)
            {
                if (orderInShipping.VehicleTypeId != entity.VehicleTypeId)
                {
                    VehicleType oldVehicleType = null;
                    VehicleType newVehicleType = null;

                    if (orderInShipping.VehicleTypeId.HasValue)
                    {
                        oldVehicleType = vehicleTypes.GetById(orderInShipping.VehicleTypeId.Value);
                    }

                    if (entity.VehicleTypeId.HasValue)
                    {
                        newVehicleType = vehicleTypes.GetById(entity.VehicleTypeId.Value);
                    }

                    orderInShipping.VehicleTypeId = entity.VehicleTypeId;

                    _historyService.Save(orderInShipping.Id, "fieldChangedBy",
                                         nameof(orderInShipping.VehicleTypeId).ToLowerFirstLetter(),
                                         oldVehicleType, newVehicleType, "onChangeInShipping");
                }

                _calcService.UpdateDeliveryCost(entity);
            }
        }
コード例 #4
0
        public void Execute(Tariff tariff)
        {
            var shippings = _dataService.GetDbSet <Shipping>()
                            .Where(x => x.Status == ShippingState.ShippingCreated ||
                                   x.Status == ShippingState.ShippingRequestSent ||
                                   x.Status == ShippingState.ShippingRejectedByTc)
                            .ToList();

            foreach (var shipping in shippings)
            {
                _calcService.UpdateDeliveryCost(shipping);
            }
        }
コード例 #5
0
 public void Execute(Order entity)
 {
     if (entity.ShippingId != null)
     {
         var shipping = _dataService.GetById <Shipping>(entity.ShippingId.Value);
         _calcService.UpdateDeliveryCost(shipping);
     }
     else if (entity.DeliveryCost != null)
     {
         _historyService.Save(entity.Id, "fieldChanged",
                              nameof(entity.DeliveryCost).ToLowerFirstLetter(),
                              entity.DeliveryCost, null);
         entity.DeliveryCost = null;
     }
 }
コード例 #6
0
        public void Execute(Shipping entity)
        {
            var orders = _dataService.GetDbSet <Order>()
                         .Where(x => x.ShippingId == entity.Id);

            foreach (var orderInShipping in orders)
            {
                if (orderInShipping.TarifficationType != entity.TarifficationType)
                {
                    _historyService.Save(orderInShipping.Id, "fieldChangedBy",
                                         nameof(entity.TarifficationType).ToLowerFirstLetter(),
                                         orderInShipping.TarifficationType, entity.TarifficationType, "onChangeInShipping");

                    orderInShipping.TarifficationType = entity.TarifficationType;
                }
            }
            _calcService.UpdateDeliveryCost(entity);
            UpdateShippingFromIntegrations(entity);
        }
コード例 #7
0
        public AppActionResult Run(CurrentUserDto user, IEnumerable <Order> orders)
        {
            var shippingId = orders.FirstOrDefault(x => x.Status == OrderState.InShipping)?.ShippingId;

            orders = orders.Where(x => x.Status == OrderState.Created).ToList();

            var shippingDbSet = _dataService.GetDbSet <Shipping>();
            var shipping      = shippingDbSet.GetById(shippingId.Value);

            if (shipping.Status == ShippingState.ShippingConfirmed)
            {
                shipping.Status = ShippingState.ShippingRequestSent;

                string orderNumbers = string.Join(", ", orders.Select(x => x.OrderNumber));
                _historyService.Save(shipping.Id, "shippingAddOrdersResendRequest", shipping.ShippingNumber, orderNumbers);
            }

            var allOrders = _dataService.GetDbSet <Order>().Where(x => x.ShippingId == shipping.Id).ToList();

            allOrders.AddRange(orders);

            UnionOrderInShipping(allOrders, orders, shipping, _historyService);

            var changes       = _dataService.GetChanges <Shipping>().FirstOrDefault(x => x.Entity.Id == shipping.Id);
            var changeTracker = _changeTrackerFactory.CreateChangeTracker().TrackAll <Shipping>();

            changeTracker.LogTrackedChanges(changes);

            var vehicleTypes = _dataService.GetDbSet <VehicleType>();

            foreach (var orderForAddInShipping in orders)
            {
                if (orderForAddInShipping.VehicleTypeId != shipping.VehicleTypeId)
                {
                    VehicleType oldVehicleType = null;
                    VehicleType newVehicleType = null;

                    if (shipping.VehicleTypeId.HasValue)
                    {
                        oldVehicleType = vehicleTypes.GetById(shipping.VehicleTypeId.Value);
                    }

                    if (orderForAddInShipping.VehicleTypeId.HasValue)
                    {
                        newVehicleType = vehicleTypes.GetById(orderForAddInShipping.VehicleTypeId.Value);
                    }

                    _historyService.Save(shipping.Id, "fieldChangedBy",
                                         nameof(shipping.VehicleTypeId).ToLowerFirstLetter(),
                                         oldVehicleType, newVehicleType, "unionOrdersInExisted");

                    orderForAddInShipping.VehicleTypeId = shipping.VehicleTypeId;
                }

                if (orderForAddInShipping.TarifficationType != shipping.TarifficationType)
                {
                    _historyService.Save(orderForAddInShipping.Id, "fieldChangedBy",
                                         nameof(orderForAddInShipping.TarifficationType).ToLowerFirstLetter(),
                                         orderForAddInShipping.TarifficationType, shipping.TarifficationType, "unionOrdersInExisted");

                    orderForAddInShipping.TarifficationType = shipping.TarifficationType;
                }
            }

            _calcService.UpdateDeliveryCost(shipping);

            return(new AppActionResult
            {
                IsError = false,
                Message = "shippingSetCreated".Translate(user.Language, shipping.ShippingNumber)
            });
        }
コード例 #8
0
 public void Execute(Shipping shipping)
 {
     _calcService.UpdateDeliveryCost(shipping);
 }