public ActionResult <Todo> DeleteTodo(long id) { Todo todoOptional = todoRepository.FindById(id); if (todoOptional != null) { todoRepository.Delete(todoOptional); return(Ok()); } return(NotFound()); }
public void Delete_ValidInput_ReturnsResult() { //Act var initial = _todoRepository.GetOne((ObjectId)_testTodo.Id); _todoRepository.Delete(id: (ObjectId)_testTodo.Id); var deleted = _todoRepository.GetOne((ObjectId)_testTodo.Id); //Assert Assert.True(initial != null); Assert.True(deleted == null); }
public async Task <IActionResult> DeleteTodo([FromBody] TodoItem item) { _iTodoRepo.Delete(item); await _context.SaveChangesAsync(); return(Ok(HttpStatusCode.OK)); }
public async Task <IActionResult> DeleteTodo(int userId, int id) { var userTokenId = int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value); if (userId != userTokenId) { _log = "'DeleteTodo' Error: 'Unauthorized' on user with id: '" + userId + "' and on todo with id: '" + id + "' from user with id: '" + userTokenId + "'"; _logger.Warning(_log); return(Unauthorized()); } var user = await _repo.GetUser(userId); if (user.Todos.All(p => p.Id != id)) { return(Unauthorized()); } var todoFromRepo = await _repo.GetTodo(id); _repo.Delete(todoFromRepo); if (await _repo.SaveAll()) { _log = "'DeleteTodo' Successful: on user with id: '" + userId + "' and on todo with id: '" + id + "' from user with id: '" + userTokenId + "'"; _logger.Information(_log); return(Ok()); } _log = "'DeleteTodo' Error: 'Bad Request' on user with id: '" + userId + "' and on todo with id: '" + id + "' from user with id: '" + userTokenId + "'"; _logger.Warning(_log); return(BadRequest("Failed to delete the todo")); }
public async Task <IActionResult> Delete(Guid id) { ApplicationUser currentUser = await _userManager.GetUserAsync(HttpContext.User); _repository.Delete(id, Guid.Parse(currentUser.Id)); return(RedirectToAction("SeeCompleted")); }
public async Task <IActionResult> Delete(long id) { var post = await _repo.GetTodo(id); if (post == null) { return(new NotFoundResult()); } await _repo.Delete(id); return(new OkResult()); }
public async Task <bool> Handle(DeleteTodoCommand request, CancellationToken cancellationToken) { var entity = await m_repo.Get(request.Id); await m_repo.Delete(entity); return(true); }
public void DeleteData(string id) { if (string.IsNullOrWhiteSpace(id)) { throw new ArgumentNullException("id"); } _repository.Delete(id); }
public void Delete(int id) { var findTodo = _todoRepository.FindById(id); if (findTodo != null) { _todoRepository.Delete(findTodo); } }
public IActionResult OnPost() { if (TodoItem != null) { repo.Delete(TodoItem.Id); } return(Redirect("/")); }
public void Delete(string id) { var todoIdGuid = Guid.Parse(id); var todo = repository.Get(a => a.Id == todoIdGuid).FirstOrDefault(); if (todo != null) { repository.Delete(todo); } }
public IActionResult Delete(int Id) { var delItem = TodoRepository.Delete(Id); if (delItem == null) { return(BadRequest()); } return(new ObjectResult(delItem)); }
public IActionResult DeleteItem(int id) { if (id <= 0) { return(NotFound()); } repo.Delete(id); return(Ok()); }
public IActionResult DeleteItem(int id) { if (_repository.Delete(id)) { return(new HttpStatusCodeResult(204)); // 201 No Content } else { return(HttpNotFound()); } }
public IActionResult Delete(long id) { var item = _repository.Get(id); if (item == null) { return BadRequest(); } _repository.Delete(item); return new NoContentResult(); }
public Boolean deleteById(int id) { var todo = todoRepository.FindById(id); if (todo != null) { todoRepository.Delete(todo); return(true); } return(false); }
public Todo Delete(Todo todo) { if (todo.Invalid) { return(todo); } _todoRepository.Delete(todo); return(todo); }
public IActionResult Delete(string key) { var result = _todoRepository.Delete(key); if (!result) { return(HttpBadRequest()); } return(Ok()); }
public ActionResult Delete(int id) { var todoItem = _todoRepository.Get(id); if (todoItem != null) { _todoRepository.Delete(todoItem); return(NoContent()); } return(BadRequest()); }
public IActionResult Delete(long id) { var todoItem = _todoRepository.Get(id); if (todoItem == null) { return(NotFound("Todo record couldn't be found.")); } _todoRepository.Delete(todoItem); return(NoContent()); }
public IActionResult Delete(int id) { var productionorder = _todoitemRepository.GetById(id); if (productionorder == null) { return(NotFound()); } _todoitemRepository.Delete(productionorder); return(NoContent()); }
public async Task <IActionResult> Delete(string id) { var _todo = await _repository.Get(id); if (_todo == null) { return(NotFound()); } await _repository.Delete(id); return(NoContent()); }
public ActionResult Delete([FromBody] int id) { if (id <= 0) { return(NotFound()); } else { repository.Delete(id); return(Ok()); } }
public ActionResult Delete(int id) { var todo = _repository.Get(id); if (todo == null) { return(BadRequest()); } _repository.Delete(todo); return(NoContent()); }
public async Task <ActionResult> Delete([FromBody] Todo todo) { var itemToDelete = await _todoRepository.Get(todo.ID); if (itemToDelete == null) { return(NotFound()); } await _todoRepository.Delete(itemToDelete.ID); return(NoContent()); }
public async Task <IActionResult> Delete(string todo) { var todoFromDb = await _todoRepository.GetTodo(todo); if (todoFromDb == null) { return(new NotFoundResult()); } await _todoRepository.Delete(todo); return(new OkResult()); }
public async Task <IActionResult> Delete([FromServices] ITodoRepository repository, [FromRoute] int id) { try { await repository.Delete(id); return(Ok()); } catch (Exception e) { return(BadRequest(e.Message)); } }
public async Task <IHttpActionResult> Delete(int id) { var model = await _todoRepository.GetSingleAsync(id); if (model == null) { return(NotFound()); } _todoRepository.Delete(model); await UnitOfWork.SaveChangesAsync(); return(Ok()); }
public IActionResult Delete(string id) { TodoItem item = _repository.GetOne(id); if (item != null) { _repository.Delete(item); _repository.CommitChanges(); return(Ok("Task Deleted")); } return(NotFound()); }
public bool DeleteTodoItem(int itemId) { var item = repository.Get(itemId); var isCurrentUserOwner = item != null && (item.Owner == User.GetId() || true); if (isCurrentUserOwner) { repository.Delete(itemId); return(true); } return(false); }