예제 #1
0
        NoteDC INotepad.AddNote(int userID, string noteDescription, string noteText)
        {
            try
            {
                Note note = new Note
                {
                    Description = noteDescription,
                    Content = noteText,
                    User_Id = userID
                };

                using (var context = new NotepadSharedEntities())
                {
                    context.Note.Add(note);
                    context.SaveChanges();
                }
                return new NoteDC
                {
                    NoteId = note.Id,
                    Description = note.Description,
                    NoteText = note.Content,
                    UserId = note.User_Id
                };
            }
            catch
            {
                return null;
            }
        }
예제 #2
0
        void INotepad.AddNoteToGroup(int noteID, int groupID)
        {
            try
            {
                GroupNote gnot = new GroupNote
                {
                    Note_Id = noteID,
                    Group_Id = groupID
                };

                using (var context = new NotepadSharedEntities())
                {
                    context.GroupNote.Add(gnot);
                    context.SaveChanges();
                }
            }
            catch { }
        }
예제 #3
0
        void INotepad.AddGroup(string groupName, string groupDescription)
        {
            try
            {
                Group group = new Group
                {
                    Name = groupName,
                    Description = groupDescription
                };

                using (var context = new NotepadSharedEntities())
                {
                    context.Group.Add(group);
                    context.SaveChanges();
                }
            }
            catch { }
        }
예제 #4
0
        UserDC INotepad.AddUser(string userName, string userPass, string userDescription)
        {
            try
            {
                User user = new User
                {
                    Name = userName,
                    Password = userPass,
                    Description = userDescription
                };

                using(var context = new NotepadSharedEntities())
                {
                    context.User.Add(user);
                    context.SaveChanges();

                    return new UserDC
                    {
                        UserId = user.Id,
                        Pass = user.Password,
                        Name = user.Name,
                        Description = user.Description
                    };
                }
            }
            catch
            {
                return null;
            }
        }
예제 #5
0
        void INotepad.UpdateUser(int userID, string userDescription)
        {
            try
            {
                using (var context = new NotepadSharedEntities())
                {
                    var user = context.User.Where(u => u.Id == userID).Single();

                    user.Description = userDescription;
                    context.SaveChanges();
                }
            }
            catch { }
        }
예제 #6
0
        void INotepad.UpdateNote(int noteID, string noteText)
        {
            try
            {
                using (var context = new NotepadSharedEntities())
                {
                    var note = context.Note.Where(n => n.Id == noteID).Single();

                    note.Content = noteText;
                    context.SaveChanges();
                }
            }
            catch { }
        }
예제 #7
0
        void INotepad.UpdateGroup(int groupID, string groupDescription)
        {
            try
            {
                using (var context = new NotepadSharedEntities())
                {
                    var gr = context.Group.Where(g => g.Id == groupID).Single();

                    gr.Description = groupDescription;
                    context.SaveChanges();
                }
            }
            catch { }
        }
예제 #8
0
        void INotepad.RemoveUserFromGroup(int userID, int groupID)
        {
            try
            {
                using (var context = new NotepadSharedEntities())
                {
                    var gu = context.GroupUser.Where(g => g.User_Id == userID
                                                       && g.Group_Id == groupID).Single();

                    context.GroupUser.Remove(gu);
                    context.SaveChanges();
                }
            }
            catch { }
        }
예제 #9
0
        void INotepad.RemoveNoteFromGroup(int noteID, int groupID)
        {
            try
            {
                using (var context = new NotepadSharedEntities())
                {
                    var gn = context.GroupNote.Where(g => g.Note_Id == noteID
                                                       && g.Group_Id == groupID).Single();

                    context.GroupNote.Remove(gn);
                    context.SaveChanges();
                }
            }
            catch { }
        }
예제 #10
0
        void INotepad.DeleteUser(int userID)
        {
            try
            {
                using (var context = new NotepadSharedEntities())
                {
                    var user = context.User.Where(u => u.Id == userID).Single();

                    context.User.Remove(user);
                    context.SaveChanges();
                }
            }
            catch { }
        }
예제 #11
0
        void INotepad.DeleteNote(int noteID)
        {
            try
            {
                using (var context = new NotepadSharedEntities())
                {
                    var note = context.Note.Where(n => n.Id == noteID).Single();

                    context.Note.Remove(note);
                    context.SaveChanges();
                }
            }
            catch { }
        }
예제 #12
0
        void INotepad.DeleteGroup(int groupID)
        {
            try
            {
                using (var context = new NotepadSharedEntities())
                {
                    var gr = context.Group.Where(g => g.Id == groupID).Single();

                    context.Group.Remove(gr);
                    context.SaveChanges();
                }
            }
            catch { }
        }
예제 #13
0
        void INotepad.AddUserToGroup(int userID, int groupID)
        {
            try
            {
                GroupUser guer = new GroupUser
                {
                    User_Id = userID,
                    Group_Id = groupID
                };

                using (var context = new NotepadSharedEntities())
                {
                    context.GroupUser.Add(guer);
                    context.SaveChanges();
                }
            }
            catch { }
        }