/// <summary> /// Получение карточки по Id инцидента /// </summary> public async Task <Result <CaseDto> > GetCaseByCaseFolderIdAsync(Guid caseFolderId, Guid userId) { using (_unitOfWork.Begin()) { var caseFolder = await _caseFolderRepository.GetById(caseFolderId); if (caseFolder == null) { _logger.Warning($"CaseFolder with Id {caseFolderId} not found"); return(Result.Failure <CaseDto>(ErrorCodes.CaseFolderNotFound)); } Result <UserClientDto> result = await _userManagementServiceClient.GetUserById(userId); if (result.IsFailure) { _logger.Warning($"User with Id {userId} not found"); return(Result.Failure <CaseDto>(ErrorCodes.UserNotFound)); } var user = _mapper.Map <UserDto>(result.Value); Result <Case> userCaseCard = caseFolder.GetCaseForUser(user.Id); if (userCaseCard.IsFailure) { _logger.Warning(userCaseCard.ErrorMessage); return(Result.Failure <CaseDto>(userCaseCard.ErrorCode)); } await NotifyGisFacadeAboutNewApplicantLocation(caseFolder, userId); return(Result.Success(CaseDto.MapFromCaseEntity(userCaseCard.Value))); } }
/// <summary> /// Получить карточку по Id /// </summary> public async Task <Result <CaseDto> > GetCaseById(Guid caseId) { using (_unitOfWork.Begin()) { var caseCard = await _caseRepository.GetById(caseId); if (caseCard == null) { _logger.Warning($"Case with Id {caseId} not found"); return(Result.Failure <CaseDto>(ErrorCodes.CaseNotFound)); } return(Result.Success(CaseDto.MapFromCaseEntity(caseCard))); } }