Exemplo n.º 1
0
        public ApplicationStateModel[] GetStateAvailability(long id)
        {
            var applicationData = _applications.Get(id);

            var states = _stateFilter.GetStateAvailabilityToSet();

            if (_identity.IsInRole(RoleType.Admin) || _identity.IsInRole(RoleType.Manager))
            {
                return(ToApplicationStateModel(states));
            }

            states = _stateFilter.FilterByBusinessLogic(applicationData, states);

            return(ToApplicationStateModel(states));
        }
Exemplo n.º 2
0
        public ApplicationListItem[] Map(ApplicationData[] data, string language)
        {
            var appIds   = data.Select(x => x.Id).ToArray();
            var stateIds = data.Select(x => x.StateId).ToArray();

            var countries         = _countries.All(language).ToDictionary(x => x.Id, x => x.Name);
            var states            = _states.Get(language, stateIds);
            var stateAvailability = _stateFilter.GetStateAvailabilityToSet();
            var calculations      = _applications.GetCalculations(appIds);
            var cps           = _files.GetInfo(appIds, ApplicationFileType.CP);
            var deliveryBills = _files.GetInfo(appIds, ApplicationFileType.DeliveryBill);
            var invoices      = _files.GetInfo(appIds, ApplicationFileType.Invoice);
            var packings      = _files.GetInfo(appIds, ApplicationFileType.Packing);
            var otherFiles    = _files.GetInfo(appIds, ApplicationFileType.Other);
            var swifts        = _files.GetInfo(appIds, ApplicationFileType.Swift);
            var torg12        = _files.GetInfo(appIds, ApplicationFileType.Torg12);
            var t1            = _files.GetInfo(appIds, ApplicationFileType.T1);
            var ex1           = _files.GetInfo(appIds, ApplicationFileType.Ex1);
            var cities        = _cities.All(language).ToDictionary(x => x.Id, x => x.Name);

            return(data.Select(x => new ApplicationListItem
            {
                CountryName = countries[x.CountryId],
                State = new ApplicationStateModel
                {
                    StateId = x.StateId,
                    StateName = states[x.StateId].LocalizedName
                },
                CanClose = x.StateId == _stateConfig.CargoOnTransitStateId,
                CanSetState = stateAvailability.Contains(x.StateId),
                AddressLoad = x.AddressLoad,
                Id = x.Id,
                FactoryName = x.FactoryName,
                Invoice = x.Invoice,
                MarkName = x.MarkName,
                Volume = x.Volume,
                Count = x.Count,
                AirWaybill = x.AirWaybill,
                Characteristic = x.Characteristic,
                ClientLegalEntity = x.ClientLegalEntity,
                ClientNic = x.ClientNic,
                ClientId = x.ClientId,
                CreationTimestamp = x.CreationTimestamp,
                DateInStock = x.DateInStock,
                DateOfCargoReceipt = x.DateOfCargoReceipt,
                FactoryContact = x.FactoryContact,
                FactoryEmail = x.FactoryEmail,
                FactoryPhone = x.FactoryPhone,
                StateChangeTimestamp = x.StateChangeTimestamp,
                StateId = x.StateId,
                TermsOfDelivery = x.TermsOfDelivery,
                TransitAddress = x.TransitAddress,
                CarrierName = x.CarrierName,
                CarrierContact = x.CarrierContact,
                CarrierAddress = x.CarrierAddress,
                CarrierPhone = x.CarrierPhone,
                TransitId = x.TransitId,
                TransitCity = cities[x.TransitCityId],
                TransitDeliveryTypeString = x.TransitDeliveryType.ToLocalString(),
                TransitMethodOfTransitString = x.TransitMethodOfTransit.ToLocalString(),
                TransitPhone = x.TransitPhone,
                TransitRecipientName = x.TransitRecipientName,
                TransitReference = x.TransitReference,
                TransitWarehouseWorkingTime = x.TransitWarehouseWorkingTime,
                WarehouseWorkingTime = x.WarehouseWorkingTime,
                Weight = x.Weight,
                MethodOfDeliveryId = (int)x.MethodOfDelivery,
                IsPickup = x.IsPickup,
                TransitMethodOfTransitId = (int)x.TransitMethodOfTransit,
                Value = x.Value,
                CurrencyId = (int)x.CurrencyId,
                AirWaybillId = x.AirWaybillId,
                PickupCost = x.GetAdjustedPickupCost(),
                FactureCost = x.GetAdjustedFactureCost(),
                FactureCostEx = x.GetAdjustedFactureCostEx(),
                ScotchCost = x.GetAdjustedScotchCost(),
                SenderName = x.SenderName,
                ForwarderName = x.ForwarderName,
                SenderScotchCost = x.SenderScotchCost,
                TariffPerKg = x.TariffPerKg,
                TransitCost = x.GetAdjustedTransitCost(),
                ForwarderTransitCost = x.TransitCost,
                CanSetTransitCost = !calculations.ContainsKey(x.Id),
                CPFiles = cps.ContainsKey(x.Id) ? cps[x.Id].ToArray() : null,
                DeliveryBillFiles = deliveryBills.ContainsKey(x.Id) ? deliveryBills[x.Id].ToArray() : null,
                InvoiceFiles = invoices.ContainsKey(x.Id) ? invoices[x.Id].ToArray() : null,
                PackingFiles = packings.ContainsKey(x.Id) ? packings[x.Id].ToArray() : null,
                OtherFiles = otherFiles.ContainsKey(x.Id) ? otherFiles[x.Id].ToArray() : null,
                SwiftFiles = swifts.ContainsKey(x.Id) ? swifts[x.Id].ToArray() : null,
                Torg12Files = torg12.ContainsKey(x.Id) ? torg12[x.Id].ToArray() : null,
                T1Files = t1.ContainsKey(x.Id) ? t1[x.Id].ToArray() : null,
                Ex1Files = ex1.ContainsKey(x.Id) ? ex1[x.Id].ToArray() : null,
                DisplayNumber = x.GetApplicationDisplay(),
                DaysInWork = x.GetDaysInWork(),
                CreationTimestampLocalString = LocalizationHelper.GetDate(x.CreationTimestamp, CultureProvider.GetCultureInfo()),
                StateChangeTimestampLocalString =
                    LocalizationHelper.GetDate(x.StateChangeTimestamp, CultureProvider.GetCultureInfo()),
                DateOfCargoReceiptLocalString =
                    x.DateOfCargoReceipt.HasValue
                                                ? LocalizationHelper.GetDate(x.DateOfCargoReceipt.Value, CultureProvider.GetCultureInfo())
                                                : null,
                DateInStockLocalString =
                    x.DateInStock.HasValue ? LocalizationHelper.GetDate(x.DateInStock.Value, CultureProvider.GetCultureInfo()) : null,
                MethodOfDeliveryLocalString = x.MethodOfDelivery.ToLocalString(),
                ValueString = GetValueString(x.Value, x.CurrencyId),
                MRN = x.MRN,
                CountInInvoce = x.CountInInvoce,
                DocumentWeight = x.DocumentWeight
            }).ToArray());
        }