public override async Task OnNavigatedToAsync(INavigationParameters parameters)
        {
            Request = parameters.GetValue <EvlRequestItemSource>(nameof(Request));

            EvlRequestExpertDto expertDto = null;

            try
            {
                expertDto = await _evlRequestService.FindEvlRequestExpert(Request.Id);

                Request.Code = expertDto.FileID;
            }
            catch (System.Exception)
            {
            }

            if (expertDto?.Expert == null)
            {
                await _dialogService.DisplayAlertAsync(ConstantStrings.Error, ConstantStrings.FindNearExpertError + System.Environment.NewLine + Request.Code, ConstantStrings.Ok);

                await NavigationService.NavigateAsync($"/{nameof(NavigationPage)}/{nameof(MainMenuView)}");
            }
            else
            {
                await NavigationService.NavigateAsync($"/{nameof(NavigationPage)}/{nameof(EvaluationRequestExpertView)}", new NavigationParameters
                {
                    { "Expert", expertDto },
                    { nameof(Request), Request }
                });
            }
        }
Esempio n. 2
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);
        }