예제 #1
0
        public ApplicationAdminModel Get(long id)
        {
            var data = _applications.Get(id);

            var transit = _transits.Get(data.TransitId).Single();

            return(new ApplicationAdminModel
            {
                AddressLoad = data.AddressLoad,
                Characteristic = data.Characteristic,
                Count = data.Count,
                Currency = new CurrencyModel
                {
                    CurrencyId = data.CurrencyId,
                    Value = data.Value
                },
                FactoryContact = data.FactoryContact,
                FactoryEmail = data.FactoryEmail,
                FactoryName = data.FactoryName,
                FactoryPhone = data.FactoryPhone,
                Weight = data.Weight,
                Invoice = data.Invoice,
                MarkName = data.MarkName,
                MethodOfDelivery = data.MethodOfDelivery,
                IsPickup = data.IsPickup,
                TermsOfDelivery = data.TermsOfDelivery,
                CountryId = data.CountryId,
                Volume = data.Volume,
                WarehouseWorkingTime = data.WarehouseWorkingTime,
                FactureCost = data.FactureCost,
                FactureCostEx = data.FactureCostEx,
                TransitCost = data.TransitCost,
                PickupCost = data.PickupCost,
                TariffPerKg = data.TariffPerKg,
                ScotchCostEdited = data.ScotchCostEdited,
                FactureCostEdited = data.FactureCostEdited,
                FactureCostExEdited = data.FactureCostExEdited,
                TransitCostEdited = data.TransitCostEdited,
                PickupCostEdited = data.PickupCostEdited,
                SenderId = data.SenderId,
                ForwarderId = data.ForwarderId,
                CarrierId = transit.CarrierId,
                InsuranceRate = data.InsuranceRate * 100,
                CountInInvoce = data.CountInInvoce,
                DocumentWeight = data.DocumentWeight,
                MRN = data.MRN,
                Comments = data.Comments
            });
        }
예제 #2
0
        public void Update(long transitId, TransitEditModel transit, long?forsedCarrierId, long?applicationId)
        {
            var data = _transits.Get(transitId).Single();

            var carrierId = GetCarrier(forsedCarrierId, transit.CityId, data.CarrierId);

            if (applicationId.HasValue && data.CarrierId != carrierId)
            {
                _events.Add(applicationId.Value, EventType.SetCarrier, EventState.Emailing);
            }

            TransitMapper.Map(transit, data, carrierId);

            _transits.Update(data);
        }
예제 #3
0
        public void Test_Add()
        {
            var clientModel = _fixture.Build <ClientModel>()
                              .With(x => x.ContractDate, DateTimeProvider.Now.ToString())
                              .With(x => x.DefaultSenderId, TestConstants.TestSenderId)
                              .Create();
            var transitEditModel = _fixture.Create <TransitEditModel>();

            transitEditModel.CityId = TestConstants.TestCityId1;

            var clientId = _manager.Add(clientModel, transitEditModel);

            var clientData  = _clientRepository.Get(clientId);
            var transitData = _transitRepository.Get(clientData.TransitId).Single();

            clientData.ShouldBeEquivalentTo(
                clientModel,
                options => options.ExcludingMissingProperties()
                .Excluding(x => x.ContractDate)
                .Excluding(x => x.InsuranceRate));
            clientData.ContractDate.ToString().ShouldBeEquivalentTo(clientModel.ContractDate);
            clientData.InsuranceRate.ShouldBeEquivalentTo(clientModel.InsuranceRate / 100);
            transitData.ShouldBeEquivalentTo(transitEditModel, options => options.ExcludingMissingProperties());
        }
예제 #4
0
        public void UpdateDeliveryData(ApplicationListItem[] applicationItems, string language)
        {
            var clientTransitIds = _clients.GetAll()
                                   .ToDictionary(x => x.TransitId, x => x.ClientId);

            var transits = _transits.Get(clientTransitIds.Select(x => x.Key).ToArray())
                           .ToDictionary(x => clientTransitIds[x.Id], x => x);

            var cities = _cities.All(language).ToDictionary(x => x.Id, x => x.Name);

            foreach (var item in applicationItems)
            {
                if (item.IsPickup)
                {
                    var transit = transits[item.ClientId];

                    item.TransitCity    = cities[transit.CityId];
                    item.CarrierContact = transit.RecipientName;
                    item.CarrierAddress = transit.Address;
                    item.CarrierPhone   = transit.Phone;
                }
            }
        }