public override async Task OnNavigatedToAsync(INavigationParameters parameters)
        {
            if (parameters.GetNavigationMode() == NavigationMode.New)
            {
                await syncData();
            }

            Request = parameters.GetValue <EvlRequestItemSource>(nameof(Request));

            SelectedCar      = Request.LostCarId != 0 ? Cars.FirstOrDefault(c => c.PrmID == Request.LostCarId) : new ExternalEntityDto();
            LostLicense      = !string.IsNullOrEmpty(Request.LostPlateNumber) ? _licenseHelper.ConvertToItemSource(Request.LostPlateNumber) : new LicensePlateItemSource();
            SelectedAlphabet = LostLicense != null?Alphabets.FirstOrDefault(c => c.Name == LostLicense.Alphabet) : new ExternalEntityDto();
        }
        public override async Task OnNavigatedToAsync(INavigationParameters parameters)
        {
            if (parameters.TryGetValue(nameof(InsuranceType), out InsuranceType insuranceType))
            {
                Request.InsuranceType = insuranceType;
            }

            if (parameters.GetNavigationMode() == NavigationMode.New)
            {
                requestCancellationTokenSource?.Cancel();
                requestCancellationTokenSource = new CancellationTokenSource();

                using (_userDialogs.Loading(ConstantStrings.Loading, cancelText: ConstantStrings.Loading_Cancel, onCancel: requestCancellationTokenSource.Cancel))
                {
                    await syncData();
                }

                if (parameters.TryGetValue(nameof(Request), out EvlRequestItemSource request))
                {
                    Request = request;

                    SelectedInsurer = Insurers.FirstOrDefault(i => i.ID == Request.InsurerId);

                    SelectedCar = Cars.FirstOrDefault(c => c.PrmID == Request.CarId);

                    License = _licenseHelper.ConvertToItemSource(Request.PlateNumber);

                    SelectedAlphabet = Alphabets.FirstOrDefault(a => a.Name == License.Alphabet);
                }
            }
            else if (parameters.GetNavigationMode() == NavigationMode.Back)
            {
                Request = parameters.GetValue <EvlRequestItemSource>(nameof(Request));

                SelectedInsurer = new InsurersItemSource();

                SelectedInsurer = Insurers.FirstOrDefault(i => i.ID == Request.InsurerId);

                //SelectedCar = Cars.FirstOrDefault(c => c.PrmID == Request.CarId);

                //License = _licenseHelper.ConvertToItemSource(Request.PlateNumber);

                //SelectedAlphabet = Alphabets.FirstOrDefault(a => a.Name == License.Alphabet);
            }
        }
Пример #3
0
        public override async Task OnNavigatedToAsync(INavigationParameters parameters)
        {
            insuranceCancellationTokenSource?.Cancel();
            insuranceCancellationTokenSource = new CancellationTokenSource();

            using (_userDialogs.Loading(ConstantStrings.Loading, cancelText: ConstantStrings.Loading_Cancel, onCancel: insuranceCancellationTokenSource.Cancel))
            {
                await syncData();

                parameters.TryGetValue("Method", out method);

                if (parameters.TryGetValue("Policy", out InsurancePolicyDto policy))
                {
                    Policy = new InsurancePolicyDto
                    {
                        CarId          = policy.CarId,
                        ChasisNo       = policy.ChasisNo,
                        ColorId        = policy.ColorId,
                        CustomerId     = policy.CustomerId,
                        Id             = policy.Id,
                        InsuranceType  = policy.InsuranceType,
                        InsurerId      = policy.InsurerId,
                        InsurerNo      = policy.InsurerNo,
                        ExpirationDate = policy.ExpirationDate,
                        PlateNumber    = policy.PlateNumber,
                        VIN            = policy.VIN
                    };

                    SelectedDate          = Policy.ExpirationDate.DateTime;
                    SelectedColor         = Colors.FirstOrDefault(c => c.PrmID == Policy.ColorId);
                    SelectedCar           = Cars.FirstOrDefault(c => c.PrmID == Policy.CarId);
                    SelectedInsuranceType = InsuranceTypes.FirstOrDefault(c => c.InsuranceType == Policy.InsuranceType);
                    SelectedInsurer       = Insurers.FirstOrDefault(c => c.ID == Policy.InsurerId);
                    License          = _licenseHelper.ConvertToItemSource(policy.PlateNumber);
                    SelectedAlphabet = Alphabets.FirstOrDefault(a => a.Name == License.Alphabet);
                }
            }
        }