예제 #1
0
        public static bool DeleteNote(long NoteId)
        {
            bool result = false;
            try
            {
                WNDataContext db = new WNDataContext();
                db.Notes.DeleteOnSubmit(db.Notes.Single(n => n.id == NoteId));
                db.SubmitChanges();
                result = true;
            }
            catch { result = false; }

            return result;
        }
예제 #2
0
        public static bool DeleteNote(long NoteId)
        {
            bool result = false;

            try
            {
                WNDataContext db = new WNDataContext();
                db.Notes.DeleteOnSubmit(db.Notes.Single(n => n.id == NoteId));
                db.SubmitChanges();
                result = true;
            }
            catch { result = false; }

            return(result);
        }
예제 #3
0
        public static bool EditNote(long NoteId, long UserId, string Title,bool isPublic, string Tag, string NoteText)
        {
            bool result = false;
            try
            {
                WNDataContext db = new WNDataContext();
                Note note = db.Notes.Single(n => n.id == NoteId);
                note.title = Title;
                note.isPublic = isPublic;
                note.content = NoteText;
                note.last_update = DateTime.Now;
                db.SubmitChanges();
                result = true;
            }
            catch { result = false; }

            return result;
        }
예제 #4
0
        public static long AddUser(string email, string password)
        {
            long userId;
            WNDataContext db = new WNDataContext();
            User user = new User();
            user.Email = email;
            user.Name = email.Split('@').Length>0?email.Split('@')[0]:"*";
            user.Password = EncDec.Encrypt(password, "webnote");
            UserRole uroles = new UserRole();
            uroles.User = user;
            uroles.RoleId = 1;
            db.UserRoles.InsertOnSubmit(uroles);
            db.SubmitChanges();

            userId = user.Id;

            return userId;
        }
예제 #5
0
        public static bool EditNote(long NoteId, long UserId, string Title, bool isPublic, string Tag, string NoteText)
        {
            bool result = false;

            try
            {
                WNDataContext db   = new WNDataContext();
                Note          note = db.Notes.Single(n => n.id == NoteId);
                note.title       = Title;
                note.isPublic    = isPublic;
                note.content     = NoteText;
                note.last_update = DateTime.Now;
                db.SubmitChanges();
                result = true;
            }
            catch { result = false; }

            return(result);
        }
예제 #6
0
        public static long AddUser(string email, string password)
        {
            long          userId;
            WNDataContext db   = new WNDataContext();
            User          user = new User();

            user.Email    = email;
            user.Name     = email.Split('@').Length > 0?email.Split('@')[0]:"*";
            user.Password = EncDec.Encrypt(password, "webnote");
            UserRole uroles = new UserRole();

            uroles.User   = user;
            uroles.RoleId = 1;
            db.UserRoles.InsertOnSubmit(uroles);
            db.SubmitChanges();

            userId = user.Id;

            return(userId);
        }
예제 #7
0
        public static bool AdNote(long userId, string title, bool isPublic, string tag, string content)
        {
            try
            {
                WNDataContext db = new WNDataContext();
                Note note = new Note();
                note.user_Id = userId;
                note.title = title;
                note.isPublic = isPublic;
                note.content = content;
                note.creation_date = DateTime.Now;
                note.last_update = DateTime.Now;

                db.Notes.InsertOnSubmit(note);
                db.SubmitChanges();
                return true;
            }
            catch (Exception e)
            {
                //TODO: log error -> medium
                return false;
            }
        }
예제 #8
0
        public static bool AdNote(long userId, string title, bool isPublic, string tag, string content)
        {
            try
            {
                WNDataContext db   = new WNDataContext();
                Note          note = new Note();
                note.user_Id       = userId;
                note.title         = title;
                note.isPublic      = isPublic;
                note.content       = content;
                note.creation_date = DateTime.Now;
                note.last_update   = DateTime.Now;

                db.Notes.InsertOnSubmit(note);
                db.SubmitChanges();
                return(true);
            }
            catch (Exception e)
            {
                //TODO: log error -> medium
                return(false);
            }
        }