Example #1
0
        public ListCollection <AirWaybillListItem> List(int take, int skip, long?brokerId, long?senderUserId, string language)
        {
            var data = _awbs.GetRange(take, skip, brokerId, senderUserId);
            var ids  = data.Select(x => x.Id).ToArray();

            var aggregates = _awbs.GetAggregate(ids).ToDictionary(x => x.AirWaybillId, x => x);

            var states         = _states.Get(language);
            var currentCulture = CultureProvider.GetCultureInfo();
            var awbFiles       = GetFileInfo(ids, AwbFileType.AWB);
            var packingFiles   = GetFileInfo(ids, AwbFileType.Packing);
            var drawFiles      = GetFileInfo(ids, AwbFileType.Draw);
            var gtdFiles       = GetFileInfo(ids, AwbFileType.GTD);
            var gtdAddFiles    = GetFileInfo(ids, AwbFileType.GTDAdditional);
            var invoiceFiles   = GetFileInfo(ids, AwbFileType.Invoice);
            var otherFiles     = GetFileInfo(ids, AwbFileType.Other);

            var items = data.Select(x => new AirWaybillListItem
            {
                Id           = x.Id,
                PackingFiles = GetFileInfo(packingFiles, x.Id),
                InvoiceFiles = GetFileInfo(invoiceFiles, x.Id),
                State        = new ApplicationStateModel
                {
                    StateName = states[x.StateId].LocalizedName,
                    StateId   = x.StateId
                },
                AWBFiles       = GetFileInfo(awbFiles, x.Id),
                OtherFiles     = GetFileInfo(otherFiles, x.Id),
                ArrivalAirport = x.ArrivalAirport,
                Bill           = x.Bill,
                CreationTimestampLocalString    = LocalizationHelper.GetDate(x.CreationTimestamp, currentCulture),
                DateOfArrivalLocalString        = LocalizationHelper.GetDate(x.DateOfArrival, currentCulture),
                DateOfDepartureLocalString      = LocalizationHelper.GetDate(x.DateOfDeparture, currentCulture),
                StateChangeTimestampLocalString = LocalizationHelper.GetDate(x.StateChangeTimestamp, currentCulture),
                DepartureAirport = x.DepartureAirport,
                GTD = x.GTD,
                GTDAdditionalFiles         = GetFileInfo(gtdAddFiles, x.Id),
                GTDFiles                   = GetFileInfo(gtdFiles, x.Id),
                DrawFiles                  = GetFileInfo(drawFiles, x.Id),
                TotalCount                 = aggregates[x.Id].TotalCount,
                TotalWeight                = aggregates[x.Id].TotalWeight,
                AdditionalCost             = x.AdditionalCost,
                TotalCostOfSenderForWeight = x.TotalCostOfSenderForWeight,
                BrokerCost                 = x.BrokerCost,
                CustomCost                 = x.CustomCost,
                FlightCost                 = x.FlightCost,
                IsActive                   = x.IsActive
            }).ToArray();

            var total = _awbs.Count(brokerId, senderUserId);

            return(new ListCollection <AirWaybillListItem> {
                Data = items, Total = total
            });
        }
Example #2
0
        public void Test_AwbRepository_Count_GetRange()
        {
            var airWaybillDatas = _awbs.Get();
            var count           = _awbs.Count();

            Assert.AreEqual(airWaybillDatas.Length, count);

            var range = _awbs.GetRange((int)count, 0);

            airWaybillDatas.ShouldBeEquivalentTo(range);
        }
Example #3
0
        private CalculationListCollection List(IList <AirWaybillData> data)
        {
            var awbs = data.ToDictionary(x => x.Id, x => x);

            var applications = _applications.GetByAirWaybill(awbs.Select(x => x.Key).ToArray()).ToArray();

            var tariffs = _senders.GetTariffs(applications.Select(x => x.SenderId ?? 0).ToArray());

            var items = GetItems(applications, tariffs);

            var info = GetInfo(data, applications, tariffs);

            var groups = GetGroups(data, items);

            return(new CalculationListCollection
            {
                Groups = groups.ToArray(),
                Total = _awbs.Count(),
                Info = info,
                TotalBalance = _balances.SumBalance().ToString("N2")
            });
        }