Пример #1
0
        public override async Task OnNavigatingToAsync(INavigationParameters parameters)
        {
            _evlRequest = parameters.GetValue <EvlRequestItemSource>(nameof(EvlRequestItemSource));

            Message         = ConstantStrings.ExpertFinding;
            IsVisibleBefore = true;
            IsVisibleAfter  = false;
            string result = null;

            EvlRequestExpertDto expertDto = await _evlRequestService.FindEvlRequestExpert(_evlRequest.Id);

            try
            {
                CustomerDto customer = await _initialDataService.GetCurrentUserInfo();

                FindExpertRequestDto findExpertDto = new FindExpertRequestDto();
                findExpertDto.UserID          = customer.Id.ToString();
                findExpertDto.RequestID       = _evlRequest.Id.ToString();
                findExpertDto.Type            = _evlRequest.InsuranceType == InsuranceType.Sales ? 2 : 1;
                findExpertDto.AccidentDate    = _dateTimeUtils.ConvertMiladiToShamsi(DateTimeOffset.Now);
                findExpertDto.MapLat          = _evlRequest.Latitude.ToString();
                findExpertDto.MapLng          = _evlRequest.Longitude.ToString();
                findExpertDto.LostName        = _evlRequest.LostFirstName;
                findExpertDto.LostFamily      = _evlRequest.LostLastName;
                findExpertDto.LostInsuranceID = 1;     // 1
                findExpertDto.LostCarID       = _evlRequest.LostCarId;
                findExpertDto.LostCarType     = "415"; // 415
                findExpertDto.Address         = "یوسف آباد کوچه هفتم";
            }
            catch (Exception ex)
            {
                await NavigationService.NavigateAsync($"/{nameof(NavigationPage)}/{nameof(MainMenuView)}");

                await _pageDialogService.DisplayAlertAsync("", ConstantStrings.FindNearExpertError, ErrorMessages.Ok);
            }

            if (result == "NotResult")
            {
                await NavigationService.NavigateAsync($"/{nameof(NavigationPage)}/{nameof(MainMenuView)}");

                await _pageDialogService.DisplayAlertAsync("", ConstantStrings.FindNearExpertNotResult, ErrorMessages.Ok);

                return;
            }


            IsVisibleBefore = false;
            IsVisibleAfter  = true;
            Message         = ConstantStrings.ExpertFind;
            if (result != null)
            {
                string[] res = result.Split('^');
                ExpertFullName = res[0];
                ExpertMobileNo = res[1];
                byte[] imageAsBytes = Convert.FromBase64String(res[2].Split(',')[1]);
                ExpertImage = ImageSource.FromStream(() => new MemoryStream(imageAsBytes));
            }

            await base.OnNavigatingToAsync(parameters);
        }
Пример #2
0
        public EvaluationRequestMenuViewModel(IEventAggregator eventAggregator, IPolicyService policyService, IUserDialogs userDialogs, IInitialDataService initialDataService, IPageDialogService dialogService)
        {
            _policyService = policyService;
            _userDialogs   = userDialogs;

            _eventAggregator = eventAggregator;

            EvlRequestBadane = new BitDelegateCommand(async() =>
            {
                await NavigationService.NavigateAsync(nameof(EvaluationRequestDetailView), new NavigationParameters
                {
                    { nameof(InsuranceType), InsuranceType.Badane }
                });
            });

            EvlRequestSales = new BitDelegateCommand(async() =>
            {
                await NavigationService.NavigateAsync(nameof(EvaluationRequestDetailView), new NavigationParameters
                {
                    { nameof(InsuranceType), InsuranceType.Sales }
                });
            });

            #region insurancePopup

            SelectPolicy = new BitDelegateCommand <PolicyItemSource>(async(policy) =>
            {
                using (_userDialogs.Loading(ConstantStrings.Loading))
                {
                    CustomerDto customer = await initialDataService.GetCurrentUserInfo();

                    eventAggregator.GetEvent <OpenInsurancePopupEvent>().Publish(new OpenInsurancePopupEvent());

                    _request.InsurerNo      = policy.InsurerNo;
                    _request.InsurerId      = policy.InsurerId;
                    _request.CarId          = policy.CarId;
                    _request.PlateNumber    = policy.PlateNumber;
                    _request.OwnerFirstName = customer.FirstName;
                    _request.OwnerLastName  = customer.LastName;

                    await NavigationService.NavigateAsync(nameof(EvaluationRequestDetailView), new NavigationParameters {
                        { "Request", _request },
                    });
                }
            });

            #endregion
        }
Пример #3
0
        public async Task syncInitialData()
        {
            await _initialDataService.GetSalesPhotos();

            await _initialDataService.GetBadanePhotos();

            await _initialDataService.GetCars();

            await _initialDataService.GetColors();

            await _initialDataService.GetCurrentUserInfo();

            await _initialDataService.GetInsurers();

            await _initialDataService.GetAlphabets();

            await _initialDataService.GetAccidentReasons();
        }
Пример #4
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);
        }