public ActionResult Delete(int id, FormCollection collection) { try { repComments.Delete(id); // TODO: Add delete logic here return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult DeleteComment(int id) { if (AuthenticationManager.LoggedUser == null) { return(RedirectToAction("Login", "Home")); } CommentsRepository commentsRepository = new CommentsRepository(new TaskManagerDb()); Comment comment = commentsRepository.GetById(id); commentsRepository.Delete(comment); return(RedirectToAction("TaskDetails", "TasksManager", new { id = comment.TaskId })); }
internal Comment Delete(int id, string userId) { Comment found = Get(id); if (found.AuthorId != userId) { throw new Exception("Invalid Request"); } if (_repo.Delete(id)) { return(found); } throw new Exception("Something went terribly wrong"); }
public async Task <Comments> DeleteComment(int id) { var entity = _comments.ReadById(id).Result; return(await _comments.Delete(entity)); }
internal string Delete(int id, string userId) { GetById(id); _repo.Delete(id, userId); return("Comment Deleted"); }