public IActionResult Delete(long id) { var todo = GetTodoWithAuthorization(id); todoService.Delete(todo); return(NoContent()); }
public async Task <IActionResult> Delete([FromRoute] int id) { var user = await GetUser(); var todo = await _todoService.GetById(id); if (todo == null) { return(BadRequest("Invalid id")); } if (user.Id != todo.User.Id) { return(Forbid()); } todo = await _todoService.Delete(id); var response = new TodoDto() { Title = todo.Title, Description = todo.Description, IsComplete = todo.IsComplete, LastUpdate = todo.LastUpdate }; return(Ok(response)); }
private void ControlRemoveTodoTask(object sender, Controls.TodoItem.RemoveTodoTaskEventArgs e) { todoControls[e.Id].Dispose(); todoControls.Remove(e.Id); _service.Delete(e.Id); _loggingController.Log(MessageType.information, "Removing TODO Item"); }
public JsonResult Delete(int id) { var todoModels = _todoService.GetById(id); _todoService.Delete(todoModels); return(Json(Url.Action("Index", "Todo"), JsonRequestBehavior.AllowGet)); }
public IActionResult Delete([FromRoute(Name = "id")] int id, [FromServices] ITodoService todos) { if (todos.Delete(id)) { return(Ok()); } return(NotFound()); }
public IActionResult Delete(int id) { if (id > 0) { var todo = _service.Get(id); var services = _service.Delete(todo).GetAwaiter().GetResult(); } return(Ok()); }
public IActionResult DeleteItem(string id) { var isDeleted = _todoService.Delete(id); if (!isDeleted) { return(NotFound()); } return(NoContent()); }
public void Delete(int id) { try { _todoService.Delete(id); } catch (Exception ex) { throw ex; } }
public async Task <ActionResult> Delete(Guid id) { var existingItem = _service.GetById(id).Result; if (existingItem == null) { return(NotFound()); } await _service.Delete(id); return(Ok()); }
public IActionResult Delete(long id) { var todo = _todoService.GetById(id); if (todo == null) { return(NotFound()); } _todoService.Delete(todo); return(NoContent()); }
public IActionResult DeleteTodo(Guid id) { try { TodoService.Delete(id); return(NoContent()); } catch (TodoNotFoundException) { return(NotFound()); } }
public async Task <IActionResult> DeleteTodo(int id) { var todoFromDb = await _todosService.GetProxyById(id); if (todoFromDb == null) { return(StatusCodeAndDtoWrapper.BuildNotFound("Specified Todo was not found")); } await _todosService.Delete(id); return(StatusCodeAndDtoWrapper.BuildSuccess("Todo Deleted Successfully")); }
public ActionResult Delete(string id) { try { var todo = _todoService.GetById(Guid.Parse(id)); _todoService.Delete(todo); } catch (Exception ex) { return(StatusCode((int)HttpStatusCode.InternalServerError, ex)); } return(Ok()); }
public IActionResult Delete(int id) { if (_todoService.Delete(id)) { TempData["success"] = "Task is successfully deleted!"; return(RedirectToAction("Index")); } else { TempData["error"] = "Some error(s) accured while task delete"; return(RedirectToAction("Index")); } }
public TodoViewModel Delete(TodoViewModel model) { var todo = _todoService.GetById(model.Id).Result; _todoService.Delete(todo); if (Commit()) { return(model); } return(null); }
public IActionResult Delete(int id) { var todo = _todoService.Delete(id); if (todo == null) { return(NotFound(new { message = "invalid todo id" })); } var todoDto = _mapper.Map <TodoDto>(todo); return(Ok(todoDto)); }
public ActionResult Delete(Guid id) { try { _todoService.Delete(id); } catch (Exception) { //Catch Error on delete, such as no exist } return(RedirectToAction("Index")); }
public IHttpActionResult DeleteTodo(int id) { Todo todo = _service.GetById(id); if (todo == null) { return(NotFound()); } _service.Delete(id); return(Ok(todo)); }
public async Task <HttpResponseMessage> DeleteTodo(int id) { var todo = await _todosService.Get(id); if (todo != null) { await _todosService.Delete(id); return(new HttpResponseMessage(HttpStatusCode.NoContent)); } return(Request.CreateResponse(HttpStatusCode.NotFound, new ErrorDtoResponse("Todo not Found"), GlobalConfiguration.Configuration.Formatters.JsonFormatter)); }
public IActionResult Delete(DeleteTodo deleteTodo) { Todo todo = new Todo { ID = deleteTodo.Id }; var result = _todoService.Delete(todo); if (result.Success) { return(Ok(result)); } return(BadRequest(result)); }
public async Task <ActionResult <Todo> > Delete(string id) { if (id == null) { return(BadRequest("Id error")); } var result = await _todoService.Delete(id); if (result == null) { return(BadRequest("Id error")); } return(result); }
public IActionResult Delete(int id) { var todo = _todoService.GetById(id); if (todo == null) { return(NotFound("Todo not exist")); } if (todo.CreatedBy != Convert.ToInt32(User.Identity.Name)) { return(Forbid("You can only remove your todo")); } _todoService.Delete(id); return(Ok()); }
public ActionResult Delete(int id) { try { _todoService.Delete(id); return(NoContent()); } catch (ArgumentNullException e) { return(NotFound(e)); } catch (Exception e) { return(BadRequest(e)); } }
public async Task <IActionResult> DeleteTodo([FromRoute] int id) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var todo = await _service.GetData(id); if (todo == null) { return(NotFound()); } await _service.Delete(id); return(Ok(todo)); }
public async Task <IActionResult> DeleteTodo(int id) { var todoFromDb = await _todoService.GetProxyById(id); if (todoFromDb == null) { return(new NotFoundObjectResult(new { Success = false, FullMessages = new[] { "Not Found" } })); } await _todoService.Delete(id); return(NoContent()); }
public Results.GenericResult Delete(int id) { var result = new Results.GenericResult(); try { result.Success = appService.Delete(id); if (!result.Success) { throw new Exception($"Todo {id} can't be deleted"); } } catch (Exception ex) { Response.StatusCode = (int)HttpStatusCode.InternalServerError; result.Errors = new string[] { ex.Message }; } return(result); }
public JsonResult DeleteTodo(int id) { var result = new Result(); try { _todoService.Delete(id); result.Success = true; } catch (Exception x) { result.Success = false; result.Error = new ErrorModel { Code = "Err-Excp", Message = x.Message }; } return(Json(result)); }
public IActionResult Delete(int id) { var result = new GenericResult(); try { result.Success = appService.Delete(new TodoDto { Id = id }); if (!result.Success) { throw new Exception($"Todo #{id} cant't be removed."); } } catch (Exception ex) { result.Errors = new string[] { ex.Message }; } return(Ok(result)); }
public IActionResult Delete(int id) { var item = _todoService.GetById(id); if (item == null) { return(NotFound()); } else { var result = _todoService.Delete(item); if (result > 0) { return(new JsonResult(new { Success = true })); } else { return(new JsonResult(new { Success = false })); } } }
public IActionResult Delete(long id) { bool found = false; try { found = _todoService.Delete(id); } catch (Exception ex) { _logger.LogCritical(ex, $"Error deleting TODO item with id={id}."); return(StatusCode(StatusCodes.Status500InternalServerError)); } if (found) { return(NotFound()); } return(NoContent()); }