コード例 #1
0
ファイル: WebNoteBiz.cs プロジェクト: hisham-elbreky/WebShell
        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
ファイル: WebNoteBiz.cs プロジェクト: hisham-elbreky/WebShell
        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
ファイル: WebNoteBiz.cs プロジェクト: hisham-elbreky/WebShell
        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
ファイル: WebNoteBiz.cs プロジェクト: hisham-elbreky/WebShell
        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);
            }
        }