Пример #1
0
 public bool UpdateAnnotation(string body, int id)
 {
     using (var db = new SOVAContext())
     {
         var anno = db.Annotations.FirstOrDefault(x => x.Id == id);
         if (anno != null)
         {
             anno.Body = body;
             db.SaveChanges();
             return(true);
         }
         return(false);
     }
 }
Пример #2
0
 // when update is run the createtionDate is updated to. Need to be fixed.
 public bool UpdateUser(int userId, string newName, string newPassword)
 {
     using (var db = new SOVAContext())
     {
         var user = db.Users.FirstOrDefault(x => x.Id == userId);
         if (user != null)
         {
             user.UserName = newName;
             user.Password = newPassword;
             db.SaveChanges();
             return(true);
         }
         return(false);
     }
 }
Пример #3
0
 public Mark CreateMarking(int postid, int userid)
 {
     using (var db = new SOVAContext())
     {
         var creationdate = DateTime.Now;
         var newmark      = new Mark()
         {
             CreationDate = creationdate,
             PostId       = postid,
             UserId       = userid
         };
         db.Marked.Add(newmark);
         db.SaveChanges();
         return(newmark);
     }
 }
Пример #4
0
 //--------------------- Searchs ----------------
 public SearchHistories SaveSearch(string newSearch, int newUserId)
 {
     using (var db = new SOVAContext())
     {
         var currentDate      = DateTime.Now;
         var newSearchHistory = new SearchHistories()
         {
             Search = newSearch,
             UserId = newUserId,
             Date   = currentDate
         };
         db.SearchHistory.Add(newSearchHistory);
         db.SaveChanges();
         return(newSearchHistory);
     }
 }
Пример #5
0
 public User CreateUser(string name, string password)
 {
     using (var db = new SOVAContext())
     {
         var creationdate = DateTime.Now;
         var newUser      = new User()
         {
             UserName     = name,
             Password     = password,
             CreationDate = creationdate
         };
         db.Users.Add(newUser);
         db.SaveChanges();
         return(newUser);
     }
 }
Пример #6
0
        //---------------- ANNOTATIONS ------------------



        public Annotations CreateAnnotation(string body, int userid, int postid)
        {
            using (var db = new SOVAContext())
            {
                var creationdate  = DateTime.Now;
                var newannotation = new Annotations()
                {
                    CreationDate = creationdate,
                    Body         = body,
                    UserId       = userid,
                    PostId       = postid
                };
                db.Annotations.Add(newannotation);
                db.SaveChanges();
                return(newannotation);
            }
        }
Пример #7
0
 public bool DeleteUser(int id)
 {
     try
     {
         using (var db = new SOVAContext())
         {
             var deluser = db.Users.Find(id);
             db.Users.Remove(deluser);
             db.SaveChanges();
         }
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Пример #8
0
 public bool DeleteAnnotation(int id)
 {
     try
     {
         using (var db = new SOVAContext())
         {
             var delannotation = new Annotations()
             {
                 Id = id
             };
             db.Annotations.Remove(delannotation);
             db.SaveChanges();
         }
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Пример #9
0
 public bool DeleteMarking(int userid, int postid)
 {
     try
     {
         using (var db = new SOVAContext())
         {
             var delmarking = new Mark()
             {
                 UserId = userid,
                 PostId = postid
             };
             db.Marked.Remove(delmarking);
             db.SaveChanges();
         }
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }