// 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>
        /// <param name="userId"></param>
        /// <param name="fieldDto"></param>
        /// <returns></returns>
        public async Task <Result> UpdateFieldAsync(Guid userId, CaseFieldDto fieldDto)
        {
            using (_unitOfWork.Begin(IsolationLevel.Serializable))
            {
                var caseFolder = await _caseFolderRepository.GetById(fieldDto.CaseFolderId);

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

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

                if (result.IsFailure)
                {
                    _logger.Warning($"User with Id {userId} not found");
                    return(Result.Failure(ErrorCodes.UserNotFound));
                }

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

                var updateResult = caseFolder.UpdateField(fieldDto.FieldId, fieldDto.Value);
                if (updateResult.IsFailure)
                {
                    _logger.Warning(updateResult.ErrorMessage);
                    return(updateResult);
                }

                var caseCard = caseFolder.GetCaseForUser(user.Id);
                if (caseCard.IsFailure)
                {
                    _logger.Warning(caseCard.ErrorMessage);
                    return(Result.Failure(caseCard.ErrorCode));
                }

                var caseStatusResult = caseCard.Value.SetStatusInProgress();
                if (caseStatusResult.IsFailure)
                {
                    _logger.Warning(caseStatusResult.ErrorMessage);
                    return(Result.Failure(caseStatusResult.ErrorCode));
                }

                await _unitOfWork.CommitAsync();

                var changeEventDto = new CaseFieldChangeEventDto
                {
                    CaseFolderId = fieldDto.CaseFolderId,
                    FieldId      = fieldDto.FieldId,
                    OperatorId   = userId
                };

                await _phoneHubMessageService.NotifyClientsAboutFieldChangedAsync(changeEventDto);

                return(Result.Success());
            }
        }
        public async Task <demoResult> UpdateField([FromBody] CaseFieldDto fieldDto)
        {
            if (fieldDto == null || !fieldDto.IsValid())
            {
                _logger.Warning($"Model not valid.");
                return(BadRequest(ErrorCodes.ValidationError));
            }

            var result = await _caseService.UpdateFieldAsync(GetUserId(), fieldDto);

            if (result.IsFailure)
            {
                return(Answer(result));
            }

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

            await CreateCaseFolder(caseData, new Guid());

            //Action
            var caseFieldDto = new CaseFieldDto
            {
                CaseFolderId = Guid.Empty,
                FieldId      = fieldId,
                Value        = fieldValue
            };

            var result = await _caseController.UpdateField(caseFieldDto);

            //Assert
            result.ShouldBeOfType <demoErrorResult>();
        }