public async Task <IActionResult> DeleteItem(int id, int listId, int itemId) { if (id != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value)) { return(Unauthorized()); } var userFromRepo = await _repo.GetUser(id); if (!userFromRepo.Lists.Any(l => l.Id == listId)) { return(Unauthorized()); } var listFromRepo = await _repo.GetList(listId); if (!listFromRepo.Items.Any(i => i.Id == itemId)) { return(BadRequest()); } var itemFromRepo = await _repo.GetItem(itemId); _repo.Delete(itemFromRepo); if (await _repo.SaveAll()) { return(Ok()); } return(BadRequest("Failed to delete the item")); }
public void RemoveToDo(int id) { var toDo = _toDoRepository.GetById(id); if (toDo != null) { _toDoRepository.Delete(toDo); } }
public ActionResult Delete(int id) { repository.Delete(id); return(Ok(new { status = "200", msg = "OK", obj = new { } })); }
/// <summary> /// This is to delete an item by id /// </summary> /// <param name="id"></param> /// <returns>This will retrun bool. If the todo item is deleted successfully then it will return true otherwise false. </returns> public async Task <bool> Delete(string id) { bool status = false; var item = await _repository.GetById(id); if (null != item) { return(await _repository.Delete(item)); } return(status); }
public HttpResponseMessage Delete(int userId, int id) { if (_todoRepository.Delete(userId, id)) { return(new HttpResponseMessage(HttpStatusCode.OK)); } else { return(new HttpResponseMessage(HttpStatusCode.NotFound)); } }
// GET: ToDoItems/Delete/5 public ActionResult Delete(int Id, ToDoItemVM model) { var ToDoItem = _repo.FindById(Id); var isSuccess = _repo.Delete(ToDoItem); if (!isSuccess) { return View(model); } return RedirectToAction(nameof(Index)); }
/// <summary> /// This is to delete an item by id /// </summary> /// <param name="id"></param> /// <returns>This will retrun bool. If the todo item is deleted successfully then it will return true otherwise false. </returns> public bool Delete(int id) { bool status = false; var item = _repository.Find(id); if (null != item) { _repository.Delete(item); status = true; } return(status); }
public ActionResult Delete(int id, IFormCollection collection) { try { _toDoRepository.Delete(SessionManager.User.Id, id); return(RedirectToAction("Index")); } catch { return(View("Error")); } }
public IActionResult RemoveTodo(Guid id) { TodoItem item = _toDoRepository.GetSingle(id); if (item == null) { return(NotFound()); } _toDoRepository.Delete(id); return(NoContent()); }
public IActionResult Delete(String id) { if (id == null) { return(BadRequest("ID must not be null")); } if (!toDoRepository.DoesItemExist(id)) { return(NotFound("Item with id " + id + " was not found")); } toDoRepository.Delete(id); return(Ok()); }
public async Task <IActionResult> DeletePhoto(int todoId, int id) { int UserId = int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value); var todo = await _repo.GetToDo(todoId, UserId); if (!todo.Images.Any(p => p.Id == id)) { return(Unauthorized()); } var photoFromRepo = await _repo.GetImage(id, UserId); if (photoFromRepo.PublicID != null) { var deleteParams = new DeletionParams(photoFromRepo.PublicID); var result = _cloudinary.Destroy(deleteParams); if (result.Result == "ok") { _repo.Delete(photoFromRepo); } } if (photoFromRepo.PublicID == null) { _repo.Delete(photoFromRepo); } if (await _repo.SaveAll()) { return(Ok()); } return(BadRequest("Failed to delete the photo")); }
public async Task <ResultData> DeleteById(int id) { var toDo = await _repository.GetById(id); if (toDo == null) { return(ErrorData(EGenericErrors.No_Records_Found.GetDescription())); } await _repository.Delete(toDo); _unitOfWork.Commit(); return(SuccessData(EGenericOperations.Record_Deleted_Successfully.GetDescription())); }
public async Task <IActionResult> DeleteTodo(int id) { int UserId = int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value); var todo = await _repo.GetToDo(id, UserId); _repo.Delete(todo); if (await _repo.SaveAll()) { return(Ok()); } return(BadRequest("Failed to delete todo")); }
private void Delete(object parameter) { try { _ToDoRepository.Delete(SelectedToDo); this.DataList = _ToDoRepository.GetAll().ToList(); this.SelectedToDo = null; } catch (Exception ex) { Logging.WriteLog("Fehler: " + ex.ToString()); MessageBox.Show("Fehler: " + ex.Message); } }
// GET /todo/delete/5 public async Task <IActionResult> Delete(int id) { // Receiving the specific item TodoList item = await _repo.Delete(id); if (item == null) { TempData["Error"] = "The item does not exist!"; } else { TempData["Success"] = "The item has been deleted!"; } return(RedirectToAction("Index")); }
public IActionResult Delete(string id) { try { var item = _toDoRepository.Find(id); if (item == null) { return(NotFound(ErrorCode.RecordNotFound.ToString())); } _toDoRepository.Delete(id); } catch (Exception) { return(BadRequest(ErrorCode.CouldNotDeleteItem.ToString())); } return(NoContent()); }
public async Task <IActionResult> DeleteTask(string userName, int id) { if (userName != (User.FindFirst(ClaimTypes.Name).Value)) { return(Unauthorized()); } var task = await toDoRepository.getToDo(userName, id); if (task != null) { toDoRepository.Delete(task); if (await toDoRepository.SaveAll()) { return(Ok("Deleted")); } return(BadRequest()); } return(NotFound()); }
public ActionResult Delete(int Id) { _toDoRepository.Delete(Id); return(RedirectToAction("Index", new { status = _status })); }
public async Task Delete(Guid id) { var entity = await _repo.GetById(id); await _repo.Delete(entity); }
public Task Remove(int id) { todoRepository.Delete(id); return(todoRepository.Save()); }
public bool Delete(int id) { return(_repository.Delete(id)); }
public void Delete(int id) { _toDoRepository.Delete(id); }
public async Task <IActionResult> Delete(int Id) { await db.Delete(Id); return(RedirectToAction("Index")); }
public async Task <int> DeleteToDoItem(int id) { var delete_result = await _repository.Delete(id); return(delete_result); }
public void Delete(int id) { _repository.Delete(id); _repository.Save(); }
public void Delete(int id) { repo.Delete(id); }
public JsonResult Delete(int Id) { _toDoRepository.Delete(Id); return(Json("")); }
public Task Handle(RemoveToDoCommand message, IMessageHandlerContext context) { _toDoRepository.Delete(message.Id); return(Task.CompletedTask); }
public void DeleteTodo(int id) { _repo.Delete(id); }