示例#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;
                }
            }
        }
示例#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);
                }
            }
        }
示例#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);
            }
        }
示例#4
0
        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);
            }
        }
示例#5
0
        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);
                }
            }
        }