예제 #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
        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 { }
        }
예제 #5
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 { }
        }
예제 #6
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 { }
        }
예제 #7
0
        List<NoteDC> INotepad.GetUserNotes(int userID)
        {
            try
            {
                using (var context = new NotepadSharedEntities())
                {
                    var notes = (from n in context.Note
                                 where n.User_Id == userID
                                 orderby n.Description ascending
                                 select new NoteDC
                                 {
                                     NoteId = n.Id,
                                     Description = n.Description,
                                     NoteText = n.Content
                                 }).ToList<NoteDC>();

                    return notes;
                }
            }
            catch
            {
                return null;
            }
        }
예제 #8
0
        UserDC INotepad.CheckUser(string userName, string userPass)
        {
            try
            {
                using (var context = new NotepadSharedEntities())
                {
                    var user = context.User.Where(u => u.Name == userName).SingleOrDefault();

                    if (user == null)
                    {
                        return null;
                    }
                    else if (user.Password.Equals(userPass))
                    {
                        return new UserDC
                        {
                            UserId = user.Id,
                            Name = user.Name,
                            Pass = user.Password,
                            Description = user.Description
                        };
                    }
                    return null;
                }
            }
            catch
            {
                return null;
            }
        }
예제 #9
0
        List<UserDC> INotepad.GetGroupUsers(int groupID)
        {
            try
            {
                using (var context = new NotepadSharedEntities())
                {
                    var gr = context.GroupUser.Where(g => g.Group_Id == groupID).Select(g => g.User_Id);

                    var users = (from u in context.User
                                 where gr.Contains(u.Id)
                                 orderby u.Description ascending
                                 select new UserDC
                                 {
                                     UserId = u.Id,
                                     Name = u.Name,
                                     Description = u.Description
                                 }).ToList<UserDC>();

                    return users;
                }
            }
            catch
            {
                return null;
            }
        }
예제 #10
0
        List<NoteDC> INotepad.GetGroupNotes(int groupID)
        {
            try
            {
                using (var context = new NotepadSharedEntities())
                {
                    var gr = context.GroupNote.Where(g => g.Group_Id == groupID).Select(g => g.Note_Id);

                    var notes = (from n in context.Note
                                 where gr.Contains(n.Id)
                                 orderby n.Description ascending
                                 select new NoteDC
                                 {
                                     NoteId = n.Id,
                                     Description = n.Description,
                                     NoteText = n.Content
                                 }).ToList<NoteDC>();

                    return notes;
                }
            }
            catch
            {
                return null;
            }
        }
예제 #11
0
        GroupDC INotepad.GetGroup(int groupID)
        {
            try
            {
                using (var context = new NotepadSharedEntities())
                {
                    var group = context.Group.Where(g => g.Id == groupID).Single();

                    return new GroupDC
                    {
                        GroupId = group.Id,
                        Name = group.Name,
                        Description = group.Description
                    };
                }
            }
            catch
            {
                return null;
            }
        }
예제 #12
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 { }
        }
예제 #13
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 { }
        }
예제 #14
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 { }
        }
예제 #15
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 { }
        }
예제 #16
0
        NoteDC INotepad.GetNote(int noteID)
        {
            try
            {
                using (var context = new NotepadSharedEntities())
                {
                    var note = context.Note.Where(n => n.Id == noteID).Single();

                    return new NoteDC
                    {
                        NoteId = note.Id,
                        Description = note.Description,
                        NoteText = note.Content
                    };
                }
            }
            catch
            {
                return null;
            }
        }
예제 #17
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 { }
        }
예제 #18
0
        UserDC INotepad.GetUser(int userID)
        {
            try
            {
                using (var context = new NotepadSharedEntities())
                {
                    var user = context.User.Where(u => u.Id == userID).Single();

                    return new UserDC
                    {
                        UserId = user.Id,
                        Name = user.Name,
                        Description = user.Description
                    };
                }
            }
            catch
            {
                return null;
            }
        }
예제 #19
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;
            }
        }
예제 #20
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 { }
        }