public HttpResponseMessage DeleteItem(int id) { _todoItemsRepo.Delete(id); var response = Request.CreateResponse(HttpStatusCode.OK); return(response); }
public void Delete(int id) { var todoItem = repository.Get(a => a.Id == id).FirstOrDefault(); if (todoItem != null) { repository.Delete(todoItem); } }
public async Task WillDeleteExistingItem() { // Arrange var item = new TodoItem { Name = "test delete", IsComplete = false }; var addedItem = await sut.Create(item); // Act await sut.Delete(addedItem.Key); var items = await sut.GetAll(); // Assert Assert.IsFalse(items.Any(x => x.Key == item.Key)); }
public OperationDetails DeleteTodoItem(TodoItemDTO todoItem) { TodoItemEntity todoItemEntity = _todoItemRepository.GetTodoItemById(todoItem.Id); if (todoItemEntity != null) { _todoItemRepository.Delete(todoItemEntity); db.Commit(); return(new OperationDetails(true, "TodoItem успешно удален", "")); } return(new OperationDetails(false, "todoItem, который должен быть удален отсутствует", "Id")); }
public TodoItemMutation(ITodoItemRepository repo) { this.repo = repo; Field <TodoItemType>( "addTodo", description: "Adds a todo to the database", arguments: new QueryArguments { new QueryArgument <TodoItemInputType>() { Name = "todo" } }, resolve: context => { var task = context.GetArgument <TodoItem>("todo"); return(repo.Add(task)); } ); Field <TodoItemType>( "updateTodo", description: "Updates a todo in the database", arguments: new QueryArguments { new QueryArgument <TodoItemInputType>() { Name = "todo" } }, resolve: context => { return(repo.Update(context.GetArgument <TodoItem>("todo"))); } ); Field <BooleanGraphType>( "deleteTodo", description: "Deletes a todo from the database", arguments: new QueryArguments { new QueryArgument <StringGraphType>() { Name = "todoId" } }, resolve: context => { return(repo.Delete(context.GetArgument <string>("todoId"))); } ); }
public async Task DeleteTodoItem(long todoItemId) { var existingValue = await _todoItemRepository.GetById(todoItemId); if (existingValue == null) { return; } _todoItemRepository.Delete(existingValue); await _todoUnitOfWork.SaveChanges(); }
public async Task Delete(TodoItem item) { if (string.IsNullOrEmpty(item.Key)) { throw new ArgumentNullException("key cannot be null"); } try { await todoItemRepository.Delete(item.Key); } catch (Exception e) { throw new Exception(e.Message); } }
public TodoModule(ITodoItemRepository repository) : base("/todo") { Get["/", true] = async (_, ct) => await repository.GetAll(); Post["/", true] = async (_, ct) => { var item = this.Bind<TodoItem>(); await repository.Store(item); return Negotiate.WithModel(item).WithStatusCode(HttpStatusCode.Created); }; Put["/{id*}", true] = async (args, ct) => { string id = args.id; var item = await repository.GetById(id); if (item == null) { return HttpStatusCode.NotFound; } var newItem = this.Bind<TodoItem>(); item.Title = newItem.Title; item.IsCompleted = newItem.IsCompleted; return item; }; Delete["/{id*}", true] = async (args, ct) => { string id = args.id; var item = await repository.GetById(id); if (item == null) { return HttpStatusCode.NotFound; } repository.Delete(item); return HttpStatusCode.OK; }; }
public async Task <JsonResult> Delete(int id) { var itemToDelete = await _todoRepo .Read(i => i.Id == id) .FirstOrDefaultAsync(); if (itemToDelete == null) { Response.StatusCode = (int)HttpStatusCode.NotFound; return(Json($"No item was found with an id of {id}")); } else { _todoRepo.Delete(itemToDelete); await _unitOfWork.SaveChangesAsync(); } return(Json($"The item with the id of {id} was deleted")); }
public async Task <ActionResult> Delete(int id) { TodoItem todoItem = await _todoItemRepository.GetTodoById(id); if (todoItem is null) { return(NotFound()); } int userId = int.Parse(User.Identity.Name); if (todoItem.UserId != userId) { return(Forbid()); } await _todoItemRepository.Delete(id); return(NoContent()); }
public async Task <IActionResult> DeleteConfirmed(int?id) { if (id == null) { return(NotFound()); } var todoItem = await _todoItemRepo .Read(item => item.Id == id) .SingleOrDefaultAsync(); if (todoItem == null) { return(NotFound()); } else { _todoItemRepo.Delete(todoItem); await _unitOfWork.SaveChangesAsync(); } return(RedirectToAction("Index")); }
public void Remove(TodoItem todoItem) { _todoItemRepo.Delete(todoItem); }
public IActionResult Delete(int id) { _todoItemRepository.Delete(id); return(Redirect("/Main/Index")); }
public async Task Delete(int id) { await _todoItemRepository.Delete(id); }
public void Delete(int id) { _repository.Delete(x => x.Id.Equals(id)); }
public async Task <bool> Delete(Guid id) { await _repository.Delete(id).ConfigureAwait(false); return(await _unitOfWork.Save().ConfigureAwait(false)); }
public async Task DeleteItemAsync(ToDoItem toDoItem) { todoItemRepository.Delete(toDoItem); await todoItemRepository.SaveAsync(); }
public async Task <ActionResult> DeleteTodo(string todoId) { await repo.Delete(todoId); return(NoContent()); }
public Task DeleteTodoItem(int todoItemId) { return(_todoItemRepository.Delete(todoItemId)); }
public async Task Delete(Guid id) { await _Repository.Delete(id); }