public long Add(ApplicationClientModel application, TransitEditModel transit, long clientId)
        {
            var transitId = _transits.Add(transit, null);

            var forwarderId = _forwarders.GetByCityOrAny(transit.CityId, null);

            var client = _clients.Get(clientId);

            var data = new ApplicationEditData
            {
                Class                = null,
                TransitId            = transitId,
                Invoice              = application.Invoice,
                Characteristic       = application.Characteristic,
                AddressLoad          = application.AddressLoad,
                WarehouseWorkingTime = application.WarehouseWorkingTime,
                Weight               = application.Weight,
                Count                = application.Count,
                Volume               = application.Volume,
                TermsOfDelivery      = application.TermsOfDelivery,
                Value                = application.Currency.Value,
                CurrencyId           = application.Currency.CurrencyId,
                CountryId            = application.CountryId,
                FactoryName          = application.FactoryName,
                FactoryPhone         = application.FactoryPhone,
                FactoryEmail         = application.FactoryEmail,
                FactoryContact       = application.FactoryContact,
                MarkName             = application.MarkName,
                MethodOfDelivery     = application.MethodOfDelivery,
                IsPickup             = application.IsPickup,
                AirWaybillId         = null,
                DateInStock          = null,
                DateOfCargoReceipt   = null,
                TransitReference     = null,
                ClientId             = clientId,
                PickupCost           = client.PickupCost,
                TransitCost          = client.TransitCost,
                FactureCost          = client.FactureCost,
                FactureCostEx        = client.FactureCostEx,
                TariffPerKg          = client.TariffPerKg,
                ScotchCostEdited     = client.ScotchCostEdited,
                FactureCostEdited    = null,
                FactureCostExEdited  = null,
                TransitCostEdited    = null,
                PickupCostEdited     = null,
                SenderId             = client.DefaultSenderId,
                SenderRate           = null,
                ForwarderId          = forwarderId,
                InsuranceRate        = client.InsuranceRate ?? _applications.GetDefaultInsuranceRate()
            };

            return(_updater.Add(data));
        }
Exemple #2
0
        public void Update(long applicationId, ApplicationClientModel application, TransitEditModel transit)
        {
            var data = _applications.Get(applicationId);

            _transits.Update(data.TransitId, transit, null, applicationId);

            var forwarderId = _forwarders.GetByCityOrAny(transit.CityId, data.ForwarderId);

            Map(application, data, forwarderId);

            _updater.Update(applicationId, data);
        }
        public virtual ActionResult Edit(
            long id,
            ApplicationClientModel model,
            [Bind(Prefix = "Transit")] TransitEditModel transitModel)
        {
            if (!ModelState.IsValid)
            {
                BindBag(id, GetClientId());

                return(View(model));
            }

            _manager.Update(id, model, transitModel);

            return(RedirectToAction(MVC.ClientApplication.Edit(id)));
        }
 private static void Map(ApplicationClientModel @from, ApplicationEditData to, long forwarderId)
 {
     to.CountryId            = @from.CountryId;
     to.Invoice              = @from.Invoice;
     to.Characteristic       = @from.Characteristic;
     to.AddressLoad          = @from.AddressLoad;
     to.WarehouseWorkingTime = @from.WarehouseWorkingTime;
     to.Weight           = @from.Weight;
     to.Count            = @from.Count;
     to.Volume           = @from.Volume;
     to.TermsOfDelivery  = @from.TermsOfDelivery;
     to.Value            = @from.Currency.Value;
     to.CurrencyId       = @from.Currency.CurrencyId;
     to.FactoryName      = @from.FactoryName;
     to.FactoryPhone     = @from.FactoryPhone;
     to.FactoryEmail     = @from.FactoryEmail;
     to.FactoryContact   = @from.FactoryContact;
     to.IsPickup         = @from.IsPickup;
     to.MarkName         = @from.MarkName;
     to.MethodOfDelivery = @from.MethodOfDelivery;
     to.ForwarderId      = forwarderId;
 }