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); } }
public History createHistory(int id, string search) { using (var db = new stackOverflowContext()) { var query = new History { userId = id, searchWord = search }; db.History.Add(query); db.SaveChanges(); Console.WriteLine("Succesfully created"); return(query); } }
public bool deleteHistory(int id) { using (var db = new stackOverflowContext()) { var delete = new History { id = id }; try { db.History.Remove(delete); db.SaveChanges(); Console.WriteLine("Succesfully deleted"); return(true); } catch (Exception e) { Console.WriteLine("Couldn't delete"); return(false); } } }