Exemple #1
0
        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;
                }
            }
        }
Exemple #2
0
        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);
                }
            }
        }
Exemple #3
0
        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);
            }
        }