Пример #1
0
        public ActionResult Delete(BankAccountViewModel bankAccountViewModel)
        {
            var bankAccount = new BankAccount()
            {
                Id = bankAccountViewModel.Id,
            };

            _bankAccountService.Delete(bankAccount);

            return(RedirectToAction("Index"));
        }
Пример #2
0
        public async Task <IActionResult> Delete(string path, CancellationToken token)
        {
            DocumentId documentId = DocumentIdTools.FromUrlEncoding(path);

            if (!documentId.Container.IsEmpty())
            {
                return(BadRequest(_noContainer));
            }

            bool response = await _service.Delete(documentId, token);

            return(response ? Ok(response) : NotFound());
        }
        public Result Delete(BankAccountDetail BankAccountDetail)
        {
            var result = new Result();

            try
            {
                BankAccountService BankAccountDetailService = new BankAccountService();
                BankAccountDetailService.Delete(BankAccountDetail);
                result.IsSuccess = true;
            }
            catch (Exception exception)
            {
                result.IsSuccess     = false;
                result.ExceptionInfo = exception;
            }
            return(result);
        }
        public async void Delete_NoErrors()
        {
            var mock  = new ServiceMockFacade <IBankAccountRepository>();
            var model = new ApiBankAccountServerRequestModel();

            mock.RepositoryMock.Setup(x => x.Delete(It.IsAny <int>())).Returns(Task.CompletedTask);
            var service = new BankAccountService(mock.LoggerMock.Object,
                                                 mock.MediatorMock.Object,
                                                 mock.RepositoryMock.Object,
                                                 mock.ModelValidatorMockFactory.BankAccountModelValidatorMock.Object,
                                                 mock.DALMapperMockFactory.DALBankAccountMapperMock);

            ActionResponse response = await service.Delete(default(int));

            response.Should().NotBeNull();
            response.Success.Should().BeTrue();
            mock.RepositoryMock.Verify(x => x.Delete(It.IsAny <int>()));
            mock.ModelValidatorMockFactory.BankAccountModelValidatorMock.Verify(x => x.ValidateDeleteAsync(It.IsAny <int>()));
            mock.MediatorMock.Verify(x => x.Publish(It.IsAny <BankAccountDeletedNotification>(), It.IsAny <CancellationToken>()));
        }
        public async void Delete_Errors()
        {
            var mock          = new ServiceMockFacade <IBankAccountRepository>();
            var model         = new ApiBankAccountServerRequestModel();
            var validatorMock = new Mock <IApiBankAccountServerRequestModelValidator>();

            validatorMock.Setup(x => x.ValidateDeleteAsync(It.IsAny <int>())).Returns(Task.FromResult(new FluentValidation.Results.ValidationResult(new List <ValidationFailure>()
            {
                new ValidationFailure("text", "test")
            })));
            var service = new BankAccountService(mock.LoggerMock.Object,
                                                 mock.MediatorMock.Object,
                                                 mock.RepositoryMock.Object,
                                                 validatorMock.Object,
                                                 mock.DALMapperMockFactory.DALBankAccountMapperMock);

            ActionResponse response = await service.Delete(default(int));

            response.Should().NotBeNull();
            response.Success.Should().BeFalse();
            validatorMock.Verify(x => x.ValidateDeleteAsync(It.IsAny <int>()));
            mock.MediatorMock.Verify(x => x.Publish(It.IsAny <BankAccountDeletedNotification>(), It.IsAny <CancellationToken>()), Times.Never());
        }