public async Task <ActionResult> DeleteList(long listID) { var success = await _service.DeleteList(listID, getID()); if (success) { return(Ok()); } return(BadRequest()); }
public IActionResult DeleteList(int id) { var result = _listService.DeleteList(id); if (!result) { return(BadRequest()); } return(NoContent()); }
public IActionResult DeleteListName(DeleteListDto deleteListDto) { if (!ModelState.IsValid) { return(BadRequest()); } bool deleteSuccessful = _listService.DeleteList(deleteListDto); if (!deleteSuccessful) { return(BadRequest()); } return(NoContent()); }
public IActionResult DeleteList([FromBody] DeleteListDto deleteListDto) { if (!ModelState.IsValid) { return(BadRequest()); } var result = _listService.DeleteList(deleteListDto); if (!result) { return(BadRequest()); } return(NoContent()); }
public async Task DeleteList_ShouldCallListRepositoryDelete() { // Data var listModel = new ListModel { Name = "todo list" }; // Setup _mockListRepository.Setup(x => x.Delete(listModel.Id, listModel.UserId)) .Returns(Task.CompletedTask).Verifiable(); // Test var listService = new ListService(_mockListRepository.Object); await listService.DeleteList(listModel.Id, listModel.UserId); // Analysis _mockListRepository.Verify(); }
public IActionResult DeleteList(int id, int boardId) { var deleteListDto = new DeleteListDto { BoardId = boardId, ListId = id }; if (deleteListDto.ListId <= 0 && deleteListDto.ListId <= 0) { return(BadRequest()); } var result = _listService.DeleteList(deleteListDto); if (!result) { return(BadRequest()); } return(NoContent()); }
public IActionResult DeleteList([FromRoute] int id, [FromRoute] int userId) { try { if (listService.GetList(id) == null) { throw new Exception("Error. List not found"); } else { listService.DeleteList(id); var l = listService.GetLists(userId); return(Ok(l)); } } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public async Task General() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: "TodoDB") .Options; using (var db = new ApplicationDbContext(options)) { var listService = new ListService(db); var userId = Guid.NewGuid().ToString(); var anotherUserId = Guid.NewGuid().ToString(); string Name1 = "Testname"; string Name2 = "Testname2"; var model = new ListModel() { OwnerId = userId, Name = Name1 }; await listService.AddList(model); var lists = await listService.GetLists(anotherUserId); Assert.AreEqual(lists.Count(), 0); lists = await listService.GetLists(userId); Assert.AreEqual(lists.Count(), 1); model.Name = Name2; await listService.AddList(model); lists = await listService.GetLists(anotherUserId); Assert.AreEqual(lists.Count(), 0); lists = await listService.GetLists(userId); Assert.AreEqual(lists.Count(), 2); var list = await listService.GetList(lists.First().Id); Assert.IsTrue(list != null); await listService.DeleteList(lists.First().Id); lists = await listService.GetLists(anotherUserId); Assert.AreEqual(lists.Count(), 0); lists = await listService.GetLists(userId); Assert.AreEqual(lists.Count(), 1); await listService.DeleteList(lists.First().Id); lists = await listService.GetLists(anotherUserId); Assert.AreEqual(lists.Count(), 0); lists = await listService.GetLists(userId); Assert.AreEqual(lists.Count(), 0); } }