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);
            }
        }
Example #3
0
        public async Task <List <PolicyItemSource> > ConvertPolicyToItemSource(IEnumerable <InsurancePolicyDto> insurances)
        {
            List <ExternalEntityDto>  cars             = new List <ExternalEntityDto>();
            List <ExternalEntityDto>  colors           = new List <ExternalEntityDto>();
            List <InsurersItemSource> insureres        = new List <InsurersItemSource>();
            List <PolicyItemSource>   policyItemSource = new List <PolicyItemSource>();

            Guid customerId = (await _initialDataService.GetCurrentUserInfo()).Id;

            cars = (await _initialDataService.GetCars()).ToList();

            colors = (await _initialDataService.GetColors()).ToList();

            insureres = (await _initialDataService.GetInsurers()).ToList();

            foreach (InsurancePolicyDto insurance in insurances)
            {
                PolicyItemSource policy = new PolicyItemSource
                {
                    CarId          = insurance.CarId,
                    InsuranceType  = insurance.InsuranceType,
                    ChasisNo       = insurance.ChasisNo,
                    ColorId        = insurance.ColorId,
                    Id             = insurance.Id,
                    InsurerNo      = insurance.InsurerNo,
                    InsurerId      = insurance.InsurerId,
                    PlateNumber    = insurance.PlateNumber,
                    VIN            = insurance.VIN,
                    ExpirationDate = insurance.ExpirationDate,
                    ColorName      = colors.FirstOrDefault(c => c.PrmID == insurance.ColorId)?.Name,
                    CarName        = cars.FirstOrDefault(c => c.PrmID == insurance.CarId)?.Name,
                    Image          = insureres.FirstOrDefault(c => c.ID == insurance.InsurerId)?.Photo,
                    IsExpired      = insurance.ExpirationDate <= DateTimeOffset.Now.AddMonths(1)
                };

                policy.LicensePlateItemSource = _licenseHelper.ConvertToItemSource(policy.PlateNumber);

                policyItemSource.Add(policy);
            }

            return(policyItemSource);
        }
Example #4
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);
                }
            }
        }
Example #5
0
        public override async Task OnNavigatedToAsync(INavigationParameters parameters)
        {
            Expert  = parameters.GetValue <EvlRequestExpertDto>(nameof(Expert));
            Request = parameters.GetValue <EvlRequestItemSource>(nameof(Request));

            CurrentPosition = new Location {
                Latitude = Expert.Expert.MapLat, Longitude = Expert.Expert.MapLng
            };

            License = _licenseHelper.ConvertToItemSource(Expert.Expert.CarPlate);

            Device.StartTimer(TimeSpan.FromSeconds(4), () =>
            {
                Task.Run(async() =>
                {
                    ExpertPositionDto postion = await _evlRequestService.UpdateExpertPosition(Expert.Token);



                    CurrentPosition = new Location {
                        Latitude = postion.Lat, Longitude = postion.Lng
                    };
                });

                if (CurrentPosition.Latitude == 0 && CurrentPosition.Longitude == 0)
                {
                    NavigationService.NavigateAsync(nameof(EvaluationRequestExpertRankView), new NavigationParameters {
                        { nameof(Request), Request },
                        { nameof(Expert), Expert }
                    });

                    return(false);
                }

                return(true);
            });
        }