public ActionResult DeleteConfirmed(int id) { var userName = GetUserName(); Client client = _repository.GetClientById(id); if (client.ClientOwner.Equals(userName)) { _repository.DeleteClient(client); } return(RedirectToAction("Index")); }
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)); }
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); }
public void DeleteClient(int id) { _clientsRepository.DeleteClient(id); }
public IActionResult RemoveClient([FromRoute] int id) { return(Ok(_service.DeleteClient(id))); }