Exemple #1
0
        public void Update(long id, AirWaybillEditData data)
        {
            var entity = _context.AirWaybills.First(x => x.Id == id);

            Map(data, entity);

            _context.SaveChanges();
        }
Exemple #2
0
 public static AwbBrokerModel GetBrokerModel(AirWaybillEditData data)
 {
     return(new AwbBrokerModel
     {
         GTD = data.GTD,
         BrokerCost = data.BrokerCost,
         CustomCost = data.CustomCost
     });
 }
Exemple #3
0
 public static void Map(AwbSenderModel from, AirWaybillEditData to)
 {
     to.Bill                       = from.Bill;
     to.ArrivalAirport             = from.ArrivalAirport;
     to.DepartureAirport           = from.DepartureAirport;
     to.DateOfArrival              = DateTimeOffset.Parse(from.DateOfArrivalLocalString);
     to.DateOfDeparture            = DateTimeOffset.Parse(from.DateOfDepartureLocalString);
     to.FlightCost                 = from.FlightCost;
     to.TotalCostOfSenderForWeight = from.TotalCostOfSenderForWeight;
 }
Exemple #4
0
        private string GetSenderName(AirWaybillEditData awb)
        {
            if (awb.SenderUserId == null)
            {
                return(null);
            }

            var senderId = _senders.GetByUserId(awb.SenderUserId.Value);

            return(senderId != null?_senders.Get(senderId.Value).Name : null);
        }
Exemple #5
0
        public static AwbSenderModel GetSenderModel(AirWaybillEditData data)
        {
            var currentCulture = CultureProvider.GetCultureInfo();

            return(new AwbSenderModel
            {
                ArrivalAirport = data.ArrivalAirport,
                Bill = data.Bill,
                DateOfArrivalLocalString = LocalizationHelper.GetDate(data.DateOfArrival, currentCulture),
                DateOfDepartureLocalString = LocalizationHelper.GetDate(data.DateOfDeparture, currentCulture),
                DepartureAirport = data.DepartureAirport,
                FlightCost = data.FlightCost,
                TotalCostOfSenderForWeight = data.TotalCostOfSenderForWeight
            });
        }
Exemple #6
0
 public static void Map(AwbAdminModel from, AirWaybillEditData to)
 {
     to.ArrivalAirport   = from.ArrivalAirport;
     to.Bill             = from.Bill;
     to.DepartureAirport = from.DepartureAirport;
     to.GTD                        = from.GTD;
     to.BrokerId                   = from.BrokerId;
     to.DateOfArrival              = DateTimeOffset.Parse(from.DateOfArrivalLocalString);
     to.DateOfDeparture            = DateTimeOffset.Parse(from.DateOfDepartureLocalString);
     to.AdditionalCost             = from.AdditionalCost;
     to.BrokerCost                 = from.BrokerCost;
     to.CustomCost                 = from.CustomCost;
     to.FlightCost                 = from.FlightCost;
     to.TotalCostOfSenderForWeight = from.TotalCostOfSenderForWeight;
     to.SenderUserId               = from.SenderUserId;
 }
Exemple #7
0
 private static void Map(AirWaybillEditData @from, AirWaybill to)
 {
     to.ArrivalAirport   = @from.ArrivalAirport;
     to.Bill             = @from.Bill;
     to.BrokerId         = @from.BrokerId;
     to.SenderUserId     = from.SenderUserId;
     to.DateOfArrival    = @from.DateOfArrival;
     to.DateOfDeparture  = @from.DateOfDeparture;
     to.DepartureAirport = @from.DepartureAirport;
     to.GTD                        = @from.GTD;
     to.AdditionalCost             = @from.AdditionalCost;
     to.BrokerCost                 = @from.BrokerCost;
     to.CustomCost                 = @from.CustomCost;
     to.FlightCost                 = @from.FlightCost;
     to.TotalCostOfSenderForWeight = from.TotalCostOfSenderForWeight;
 }
Exemple #8
0
        public long Add(AirWaybillEditData data, long stateId, long creatorUserId)
        {
            var entity = new AirWaybill
            {
                CreationTimestamp    = DateTimeProvider.Now,
                StateChangeTimestamp = DateTimeProvider.Now,
                StateId       = stateId,
                IsActive      = true,
                CreatorUserId = creatorUserId
            };

            Map(data, entity);

            _context.AirWaybills.InsertOnSubmit(entity);

            _context.SaveChanges();

            return(entity.Id);
        }
Exemple #9
0
        public static AwbAdminModel GetAdminModel(AirWaybillEditData data)
        {
            var cultureInfo = CultureProvider.GetCultureInfo();

            return(new AwbAdminModel
            {
                ArrivalAirport = data.ArrivalAirport,
                Bill = data.Bill,
                DateOfArrivalLocalString = LocalizationHelper.GetDate(data.DateOfArrival, cultureInfo),
                DateOfDepartureLocalString = LocalizationHelper.GetDate(data.DateOfDeparture, cultureInfo),
                DepartureAirport = data.DepartureAirport,
                GTD = data.GTD,
                BrokerId = data.BrokerId,
                AdditionalCost = data.AdditionalCost,
                BrokerCost = data.BrokerCost,
                CustomCost = data.CustomCost,
                FlightCost = data.FlightCost,
                TotalCostOfSenderForWeight = data.TotalCostOfSenderForWeight,
                SenderUserId = data.SenderUserId
            });
        }
Exemple #10
0
        public long Create(long?applicationId, AirWaybillEditData data, long creatorUserId)
        {
            if (data.GTD != null)
            {
                throw new InvalidLogicException("GTD data should be defined by update");
            }

            var id = _awbs.Add(data, _stateConfig.CargoIsFlewStateId, creatorUserId);

            if (applicationId.HasValue)
            {
                _applicationAwbManager.SetAwb(applicationId.Value, id);
            }

            if (data.BrokerId.HasValue)
            {
                _events.Add(id, EventType.SetBroker, EventState.Emailing);
            }

            _events.Add(id, EventType.AwbCreated, EventState.Emailing, data);

            return(id);
        }
Exemple #11
0
 public static void Map(AwbBrokerModel from, AirWaybillEditData to)
 {
     to.GTD        = from.GTD;
     to.BrokerCost = from.BrokerCost;
     to.CustomCost = from.CustomCost;
 }