// ReSharper disable once InconsistentNaming
        public async void UpdateField_WithValidId_SuccessfullyUpdated()
        {
            //Arrange
            var  fieldId    = new Guid("81fa8ce9-e2e6-0001-0001-000000000001");
            var  fieldValue = "Fire";
            var  caseData   = $"[{{\"fieldId\":\"{fieldId.ToString()}\",\"blockId\":\"81fa8ce9-e2e6-0001-0001-000000000000\",\"value\":\"SomeValue\"}}]";
            Guid userId     = UsersMetadata.UserIdOperator112;

            var caseFolderId = await CreateCaseFolder(caseData, userId);

            //Action
            string caseDataDto;
            var    caseFieldDto = new CaseFieldDto
            {
                CaseFolderId = caseFolderId,
                FieldId      = fieldId,
                Value        = fieldValue,
            };

            SetCurrentUserId(userId);
            var result = await _caseController.UpdateField(caseFieldDto);

            using (_unitOfWork.Begin())
            {
                var caseFolder = await _caseFolderRepository.GetById(caseFolderId);

                caseDataDto = caseFolder.Data;
            }

            //Assert
            result.ShouldBeOfType <demoResult>();
            result.HttpStatusCode.ShouldBe(HttpStatusCode.OK);
            caseDataDto.ShouldContain(fieldValue);
        }
        /// <summary>
        /// Перезвонить заявителю
        /// </summary>
        public async Task <Result <CallBackToApplicantStatus> > CallBackToApplicant(Guid userId, CallBackToApplicantDto model)
        {
            using (_unitOfWork.Begin())
            {
                var        caseFolderId = model.CaseFolderId;
                CaseFolder caseFolder   = await _caseFolderRepository.GetById(caseFolderId);

                if (caseFolder == null)
                {
                    _logger.Warning($"CaseFolder with Id {caseFolderId} not found");
                    return(Result.Failure <CallBackToApplicantStatus>(ErrorCodes.CaseFolderNotFound));
                }

                var participantResult = await GetApplicant(caseFolder);

                if (participantResult.IsFailure)
                {
                    _logger.Warning(participantResult.ErrorMessage);
                    return(Result.Failure <CallBackToApplicantStatus>(participantResult.ErrorCode));
                }

                Result <UserClientDto> userResult = await _userManagementServiceClient.GetUserById(userId);

                if (userResult.IsFailure)
                {
                    _logger.Warning($"CallBackToApplicant. Error get user by Id. {userResult.ErrorMessage}");
                    return(Result.Failure(ErrorCodes.UserNotFound));
                }

                var user = _mapper.Map <UserDto>(userResult.Value);

                var clientModel = new CallBackToApplicantClientDto
                {
                    UserExtension        = user.Extension,
                    ParticipantExtension = participantResult.Value.ParticipantExtension,
                    CaseFolderId         = caseFolderId,
                };
                var result = await _callManagementServiceClient.CallBackToApplicant(clientModel);

                if (result.IsFailure)
                {
                    _logger.Warning($"CallBackToApplicant. {result.ErrorMessage}");
                    return(Result.Failure <CallBackToApplicantStatus>(ErrorCodes.UnableToCallBackToApplicant));
                }

                await _unitOfWork.CommitAsync();

                await _phoneHubMessageService.NotifyUserAboutStartedExternalCall(userId, result.Value.LineId);

                return(Result.Success(CallBackToApplicantStatus.Ok));
            }
        }
예제 #3
0
        /// <summary>
        /// Получить инцидент по Id
        /// </summary>
        public async Task <Result <CaseFolderListItemDto> > Get(Guid caseFolderId)
        {
            using (_unitOfWork.Begin())
            {
                var caseFolder = await _caseFolderRepository.GetById(caseFolderId);

                if (caseFolder == null)
                {
                    _logger.Warning($"CaseFolder not found");
                    return(Result.Failure <CaseFolderListItemDto>(ErrorCodes.CaseFolderNotFound));
                }

                var caseFolderListItem = CaseFolderListItemDto.MapFromCaseEntity(caseFolder);

                _logger.Debug($"Найден инцидент по id {caseFolderId}.");

                return(Result.Success(caseFolderListItem));
            }
        }
예제 #4
0
        /// <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)));
            }
        }