/// <summary> /// Сделать запрос в GisFacade для создания маркера местоположения заявителя. /// </summary> /// <param name="applicantLocationDto"></param> /// <returns></returns> public async Task <Result> AddApplicantLocationOnMapAsync(CaseApplicantDto applicantLocationDto) { using (_unitOfWork.Begin()) { var caseFolderId = applicantLocationDto.CaseFolderId; var caseFolder = await _caseFolderRepository.GetById(caseFolderId); if (caseFolder == null) { _logger.Warning($"CaseFolder with Id {caseFolderId} not found"); return(Result.Failure(ErrorCodes.CaseFolderNotFound)); } var locationDataResult = caseFolder.GetLocationData(); if (locationDataResult.IsFailure) { _logger.Warning(locationDataResult.ErrorMessage); return(Result.Failure(locationDataResult.ErrorCode)); } var location = locationDataResult.Value; var locationDto = _mapper.Map <LocationDataClientDto>(location); var addLocationResult = await _gisFacadeClient.AddApplicantLocationMarker(caseFolderId, locationDto); if (addLocationResult.IsFailure) { _logger.Warning($"AddApplicantLocationOnMapAsync. Failed to add applicant location. {addLocationResult.ErrorMessage}"); return(Result.Failure(ErrorCodes.UnableToAddApplicantLocationMarker)); } await _phoneHubMessageService.NotifyClientsAboutApplicantLocationUpdateAsync(caseFolderId, AuthorizationContext.CurrentUserId.Value); return(addLocationResult); } }
public async Task <demoResult> ShowApplicantLocationOnMap([FromBody] CaseApplicantDto caseApplicantDto) { if (caseApplicantDto == null || !caseApplicantDto.IsValid()) { _logger.Warning($"Model {nameof(caseApplicantDto)} not valid"); return(BadRequest(ErrorCodes.ValidationError)); } var result = await _caseService.AddApplicantLocationOnMapAsync(caseApplicantDto); if (result.IsFailure) { return(BadRequest(result.ErrorCode)); } return(Ok()); }
/// <summary> /// Сделать запрос в GisFacade для создания маркера инцидента по местоположению заявителя. /// </summary> /// <param name="userId"></param> /// <param name="caseApplicantDto"></param> /// <returns></returns> public async Task <Result> UseApplicantLocationAsIncidentLocationAsync(Guid userId, CaseApplicantDto caseApplicantDto) { using (_unitOfWork.Begin()) { var caseFolderId = caseApplicantDto.CaseFolderId; var caseFolder = await _caseFolderRepository.GetById(caseFolderId); if (caseFolder == null) { _logger.Warning($"CaseFolder with Id {caseFolderId} not found"); return(Result.Failure(ErrorCodes.CaseFolderNotFound)); } var locationDataResult = caseFolder.GetLocationData(); if (locationDataResult.IsFailure) { _logger.Warning(locationDataResult.ErrorMessage); return(Result.Failure(locationDataResult.ErrorCode)); } var position = locationDataResult.Value; caseFolder.Latitude = position.Position.Latitude; caseFolder.Longitude = position.Position.Longitude; await _unitOfWork.CommitAsync(); var addLocationResult = await _gisService.AddIncidentMarkerToMap( caseFolderId, position.Position.Latitude, position.Position.Longitude); if (addLocationResult.IsFailure) { _logger.Warning(addLocationResult.ErrorMessage); } await _phoneHubMessageService.NotifyClientsAboutIncidentLocationUpdateAsync(caseFolderId, userId); await _phoneHubMessageService.NotifyClientsAboutLocationUpdateAsync(caseFolderId, userId); return(Result.Success()); } }