public ActionResult <TransactionGetDto> Post([FromBody][Required] TransactionPostDto value)
        {
            // Validate
            var validateResult = _dtoValidationService.ValidateTransferDto(value);

            if (validateResult.HasErrors())
            {
                ModelState.AddErrors(validateResult);
            }

            if (!ModelState.IsValid)
            {
                _logger.LogStateWarning("This model is invalid.", ModelState);
                return(BadRequest(ModelState));
            }

            // Work
            var user = _userRepository.GetUser(User.Identity.Name);

            if (user == null)
            {
                return(Forbid());
            }

            var(transaction, transferResult) = _bankService.TryTransferMoney(
                user,
                value.Sum,
                value.From,
                value.To);

            if (transferResult.HasErrors())
            {
                ModelState.AddErrors(transferResult);
                _logger.LogStateError("Transferring was unsuccessfully.", ModelState);

                return(BadRequest(ModelState));
            }

            var cardFromNumber = value.From.ToNormalizedCardNumber();

            var dto = _dtoFactory.Map(transaction, TryValidateModel);

            switch (dto)
            {
            // Validate
            case null:
                _logger.LogError("Transferring was unsuccessfully.");
                return(BadRequest("Transferring error"));

            default:
                return(Created($"/transactions/{cardFromNumber}", dto));
            }
        }
        public void ValidateTransferDto_WrongFromCard_Error()
        {
            // Arrange
            var transaction = new TransactionPostDto
            {
                From = WrongCardNumber,
                To   = TrueCardNumber,
                Sum  = 1
            };

            // Act
            var errors = _dtoValidationService.ValidateTransferDto(transaction);

            // Assert
            _cardCheckerMock.Verify(x => x.CheckCardEmitter(WrongCardNumber), Times.Once);
            _cardCheckerMock.Verify(x => x.CheckCardEmitter(TrueCardNumber), Times.Once);

            Assert.Single(errors);
            Assert.Equal("from", errors.First().FieldName);
            Assert.Equal("Card number is invalid", errors.First().Message);
            Assert.Equal("Номер карты неверный", errors.First().LocalizedMessage);
        }