Exemple #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            var    userName = GetUserName();
            Client client   = _repository.GetClientById(id);

            if (client.ClientOwner.Equals(userName))
            {
                _repository.DeleteClient(client);
            }
            return(RedirectToAction("Index"));
        }
Exemple #2
0
        public async Task <ActionResult> DeleteClient(Guid clientId)
        {
            var clientFromRepo = await _clientsRepo.GetClientById(clientId);

            if (clientFromRepo == null)
            {
                return(NotFound());
            }

            await _clientsRepo.DeleteClient(clientId);

            return(NoContent());
        }
        public async Task ShouldNotToDeleteClientAsync()
        {
            // Arrange
            using var factory         = new SQLiteDbContextFactory();
            await using var dbContext = factory.CreateContext();
            _clientService            = new BankApplication.Service.Service.ClientService(dbContext, _mapper);
            int clientId = 6;

            //Act
            var response = _clientService.DeleteClient(clientId);

            // Assert
            Assert.IsFalse(response);
            Assert.AreEqual(5, dbContext.Clients.Count());
            Assert.IsNull(dbContext.Clients.Find(clientId));
        }
        public async Task ShouldBeAbleToDeleteClientAsync()
        {
            // Arrange
            using var factory         = new SQLiteDbContextFactory();
            await using var dbContext = factory.CreateContext();
            _service = new Service.Service.ClientService(dbContext, _mapper);
            int clientId = 1;

            //Act
            var response = _service.DeleteClient(clientId);

            // Assert
            Assert.IsTrue(response);
            Assert.AreEqual(3, dbContext.Clients.Count());
            Assert.IsNull(dbContext.Clients.Find(clientId));
        }
Exemple #5
0
        public async Task DeleteClient_ShouldNotWork()
        {
            using var factory         = new SQLiteDbContextFactory();
            await using var dbContext = factory.CreateContext();
            clientsRepository         = new ClientService(dbContext, mapper);

            //Arrange
            var clientId      = 24;
            var expectedCount = await dbContext.Clients.CountAsync();

            //Actual
            var actual      = clientsRepository.DeleteClient(clientId);
            var actualCount = await dbContext.Clients.CountAsync();

            //Assert
            Assert.False(actual);
            Assert.Equal(expectedCount, actualCount);
        }
Exemple #6
0
 public void DeleteClient(int id)
 {
     _clientsRepository.DeleteClient(id);
 }
Exemple #7
0
 public IActionResult RemoveClient([FromRoute] int id)
 {
     return(Ok(_service.DeleteClient(id)));
 }