Пример #1
0
        public virtual async Task UpdateRequestStatus(UpdateRequestStatusArgs args, CancellationToken cancellationToken)
        {
            EvlRequest evlReq = await EvlRequestsRepository.GetByIdAsync(cancellationToken, args.evlRequestId);

            evlReq.Status = args.status;
            await EvlRequestsRepository.UpdateAsync(evlReq, cancellationToken);
        }
Пример #2
0
        public virtual async Task <EvlRequestDto> UpdateRank(SubmitRankArgs args, CancellationToken cancellationToken)
        {
            EvlRequest evlRequest = await(await EvlRequestsRepository.GetAllAsync(cancellationToken)).FirstOrDefaultAsync(r => r.Id == args.evlRequestId);

            evlRequest.RankValue       = args.Rank;
            evlRequest.RankDescription = args.Description;

            return(Mapper.FromEntityToDto((await EvlRequestsRepository.UpdateAsync(evlRequest, cancellationToken))));
        }
Пример #3
0
        public virtual async Task <EvlRequestExpertDto> FindEvlRequestExpert(FindEvlReqeustExpertArgs args, CancellationToken cancellationToken)
        {
            EvlRequest evlRequest = await(await EvlRequestsRepository.GetAllAsync(cancellationToken)).Where(e => e.Id == args.requestId).Include(c => c.Customer).FirstOrDefaultAsync();

            if (evlRequest == null)
            {
                throw new ResourceNotFoundException("evlRequest is null");
            }

            List <EvlRequestFile> requestFiles = await(await EvlRequestFileRepository.GetAllAsync(cancellationToken)).Where(e => e.EvlRequestId == evlRequest.Id).ToListAsync();

            HttpClient httpClient = HttpClientFactory.CreateClient("SoltaniHttpClient");
            SoltaniFindExpertRequest soltaniFindExpertParams = new SoltaniFindExpertRequest();

            soltaniFindExpertParams.UserID    = evlRequest.CustomerId;
            soltaniFindExpertParams.RequestID = evlRequest.Id;
            soltaniFindExpertParams.Type      = (short)evlRequest.InsuranceType;
            DefaultDateTimeUtils defaultDateTimeUtils = new DefaultDateTimeUtils();

            soltaniFindExpertParams.AccidentDate = defaultDateTimeUtils.ConvertMiladiToShamsi(evlRequest.AccidentDate);
            soltaniFindExpertParams.MapLat       = evlRequest.Latitude;
            soltaniFindExpertParams.MapLng       = evlRequest.Longitude;
            soltaniFindExpertParams.Address      = "آدرس تستی";

            requestFiles.ForEach(r => soltaniFindExpertParams.Photos.Add(new RequestPhoto
            {
                Data = Convert.ToBase64String(r.File),
                Type = r.TypeId
            }));

            if (evlRequest.InsuranceType == Enums.InsuranceType.Badane)
            {
                soltaniFindExpertParams.LostName        = evlRequest.OwnerFirstName;
                soltaniFindExpertParams.LostFamily      = evlRequest.OwnerLastName;
                soltaniFindExpertParams.LostInsuranceID = evlRequest.InsurerId;
                soltaniFindExpertParams.LostCarID       = evlRequest.CarId;
                soltaniFindExpertParams.LostMobile      = evlRequest.Customer.Mobile;
            }
            else
            {
                soltaniFindExpertParams.LostName   = evlRequest.LostFirstName;
                soltaniFindExpertParams.LostFamily = evlRequest.LostLastName;
                soltaniFindExpertParams.LostMobile = evlRequest.Customer.Mobile;
                soltaniFindExpertParams.LostCarID  = evlRequest.LostCarId;

                soltaniFindExpertParams.CrmName        = evlRequest.OwnerFirstName;
                soltaniFindExpertParams.CrmFamily      = evlRequest.OwnerLastName;
                soltaniFindExpertParams.CrmInsuranceID = evlRequest.InsurerId;
                soltaniFindExpertParams.CrmInsuranceNO = evlRequest.InsurerNo;

                soltaniFindExpertParams.CrmNumberplate = evlRequest.PlateNumber;
                soltaniFindExpertParams.CrmCarID       = evlRequest.CarId;
            }
            string json = JsonConvert.SerializeObject(soltaniFindExpertParams);

            StringContent stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");

            HttpResponseMessage findExpertRawResponse = await httpClient.PostAsync("FindNearExpert", stringContent);

            try
            {
                findExpertRawResponse.EnsureSuccessStatusCode();
            }
            catch (Exception ex)
            {
                throw new DomainLogicException("FindNearExpert call failed", ex);
            }

            EvlRequestExpertDto evlRequestExpert = JsonConvert.DeserializeObject <EvlRequestExpertDto>(await findExpertRawResponse.Content.ReadAsStringAsync());

            evlRequest.Code = evlRequestExpert.FileID;

            await EvlRequestsRepository.UpdateAsync(evlRequest, cancellationToken);

            return(evlRequestExpert);
        }