public void Delete_ValidId_DeletedTodoItem() { //Arrange var id = TestHelper.TodoItems.ElementAt(2).Id; //Act var data = _todoItemService.Delete(id); //Assert Assert.Equal(id, data.Id); Assert.True(data.IsDeleted); }
public async Task WillDeleteOneItem() { // Arrange var key = Guid.NewGuid().ToString(); var item = new TodoItem { Name = "test", IsComplete = true, }; var addedItem = item; addedItem.Key = key; todoItemRepository.Create(item).Returns(addedItem); todoItemRepository.GetAll().Returns(new List <TodoItem>()); // Act await sut.Delete(item); var items = await sut.GetAll(); // Assert Assert.IsFalse(items.Any(x => x.Key == item.Key)); }
public async Task <ActionResult <TodoItem> > DeleteTodoItem(long id) { var todoItem = await _todoItemService.Delete(id); if (todoItem == null) { return(NotFound()); } return(todoItem); }
public IActionResult Delete(Guid id) { var removeItem = _todoItemService.Delete(id); if (removeItem == null) { return(BadRequest("Item does not exist in list.")); } return(Ok("Item successfully removed from list.")); }
public async Task <IBaseCommandResult> HandleDelete(long id) { var todoItem = await _todoItemService.Delete(id); if (todoItem == null) { return(new BaseCommandResult(false, "TodoItem not found", null)); } else { return(new BaseCommandResult(true, "TodoItem deleted with Success!", ItemToDto(todoItem))); } }
public async Task <IActionResult> RemoveTodoItem(Guid id) { var entity = await _service.GetById(id); if (entity == null) { return(NotFound()); } if (!await _service.Delete(entity.Id)) { throw new ApiException($"Removal of todo item {id} failed on save."); } return(NoContent()); }
public void Handle(DeleteTodoItemCommand command) { var todoItem = _todoItemService.Read(x => x.Id == command.Id).FirstOrDefault(); if (todoItem == null) { throw new NotFoundException("Objeto não encontrado.", null); } if (command.Invalid) { return; } _todoItemService.Delete((long)command.Id); }
async Task ExecuteDeleteTodoItemCommand(TodoItem item) { try { await todoItemService.Delete(item); TodoItems.Remove(item); // TODO: Remove hardcoded MessagingCenter.Send(this, "DeletedTodoItem", item); } catch (Exception e) { // TODO: Add alert Debug.WriteLine(e.Message); } }
public IActionResult Delete(int Id) { if (Id == default(int)) { return(NotFound()); } var todoItem = _todoItemService.GetById(Id); if (todoItem == default(TodoItem)) { return(NotFound()); } _todoItemService.Delete(todoItem); return(RedirectToAction("Index")); }
protected virtual async Task <IActionResult> DoDelete(string slug) { var user = await this.GetLocalUser(UserService); var todoItem = await TodoItemService.TodoItemRepository .FindOneBy(t => t.User.Id == user.Id && t.Slug == slug); if (todoItem == null) { return(NotFound()); } await TodoItemService.Delete(todoItem); var responseBody = new { Message = StatusMessageLocalizer["TodoItemDeleted"].Value }; return(Ok(responseBody)); }
public IActionResult Delete(int Id) { if (Id == default(int)) { return(NotFound()); } var todoItem = _todoItemService.GetById(Id); if (todoItem == default(TodoItem)) { return(NotFound()); } try { _todoItemService.Delete(todoItem); return(Ok()); } catch { } return(BadRequest()); }
public void Delete(int id) { service.Delete(id); }
public async Task <IActionResult> Delete(int id) { await _todoItemService.Delete(id, User); return(RedirectToAction("Index")); }
public ActionResult Delete(int id, int categoryId) { _itemService.Delete(id); return(RedirectToAction("Details", "TodoCategory", new { id = categoryId })); }
public async Task Delete(int id) { await _todoItemService.Delete(id); }
public IActionResult Delete(string id) { _itemService.Delete(id); return(NoContent()); }