예제 #1
0
 public bool DeleteAnnotation(Annotation annotation)
 {
     using var db = new SOContext();
     try
     {
         db.Annotations.Remove(annotation);
         db.SaveChanges();
         return(true);
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return(false);
     }
 }
예제 #2
0
        public bool DeleteMarking(Marking marking)
        {
            using var db = new SOContext();
            try
            {
                db.Markings.Remove(marking);
                db.SaveChanges();
                return(true);
            }
            catch (Exception e)
            {
                return(false);

                throw e;
            }
        }
예제 #3
0
        public bool UpdateAnnotation(Annotation annotation)
        {
            using var db = new SOContext();

            try
            {
                var oldAnnotation = db.Annotations.Find(annotation.AnnotationId);
                oldAnnotation.Body = annotation.Body;
                db.Annotations.Update(oldAnnotation);
                db.SaveChanges();

                return(true);
            }
            catch (Exception e)
            {
                return(false);

                throw e;
            }
        }
예제 #4
0
        public User CreateUser(string username, string password, string salt)
        {
            using var db = new SOContext();
            var user = new User()
            {
                Username = username,
                Password = password,
                Salt     = salt
            };

            try
            {
                db.Users.Add(user);
                db.SaveChanges();
                return(user);
            }
            catch (Exception e)
            {
                return(user);

                throw e;
            }
        }