public bool deleteFavourites(int userid, int postid) { using (var db = new stackOverflowContext()) { var delete = new Marking { userID = userid, postId = postid }; try { db.Marking.Remove(delete); db.SaveChanges(); Console.WriteLine("Deletion complete"); return(true); } catch (Exception e) { Console.WriteLine("Couldn't delete"); return(false); throw; } } }
public bool updateMarking(int userid, int postid, string note) { using (var db = new stackOverflowContext()) { var update = new Marking { postId = postid, userID = userid, note = note }; try { db.Marking.Update(update); db.SaveChanges(); Console.WriteLine("Updated"); return(true); } catch (Exception e) { Console.WriteLine("Couldn't update"); return(false); } } }
public Marking createMarking(int userid, int postid, string note) { using (var db = new stackOverflowContext()) { var query = new Marking { postId = postid, userID = userid, note = note }; db.Marking.Add(query); db.SaveChanges(); return(query); } }