示例#1
0
        public void DeleteNote(Guid userId, int noteId)
        {
            using(var context = new NotepadDBEntities()) {

                // find the note that matches the noteID and delete it from the DB
                var note = context.Notes.Where(n => n.NoteId.Equals(noteId)).Single();
                context.Notes.DeleteObject(note);
                context.SaveChanges();
            }
        }
 public void DeleteNote(Guid userId, int noteId)
 {
     using (var context = new NotepadDBEntities())
     {
         var note = context
                    .Notes
                    .Where(n => n.NoteId.Equals(noteId)).Single();
         context.Notes.DeleteObject(note);
         context.SaveChanges();
     }
 }
示例#3
0
 public Guid AddUser(Guid userId, string userName)
 {
     using (var context = new NotepadDBEntities()) {
         context.AddToUsers(new User() {
             UserId = userId,
             Name = userName,
         });
         context.SaveChanges();
         return userId;
     }
 }
 public void UpdateNote(int noteId, string noteText)
 {
     using (var context = new NotepadDBEntities())
     {
         var note = context
                    .Notes
                    .Where(n => n.NoteId.Equals(noteId)
                           ).Single();
         note.NoteText = noteText;
         context.SaveChanges();
     }
 }
        public Guid AddUser(Guid userId, string userName)
        {
            using (var context = new NotepadDBEntities())
            {
                context.AddToUsers(new User()
                {
                    UserId = userId,
                    Name   = userName,
                });
                context.SaveChanges();

                return(userId);
            }
        }
示例#6
0
        public NoteDto AddNote(Guid userId, string noteDescription, string noteText)
        {
            using (var context = new NotepadDBEntities()) {

                Note note = new Note() {
                    Description = noteDescription,
                    UserId = userId,
                    NoteText = noteText,
                };

            context.AddToNotes(note);
            context.SaveChanges();

                return new NoteDto() {
                    NoteId = note.NoteId,
                    Description = note.Description,
                    NoteText = note.NoteText,
                };
            }
        }
        public NoteDto AddNote(Guid userId, string notedescription, string noteText)
        {
            using (var context = new NotepadDBEntities())
            {
                Note note = new Note()
                {
                    Description = notedescription,
                    UserId      = userId,
                    NoteText    = noteText,
                };
                context.AddToNotes(note);
                context.SaveChanges();

                return(new NoteDto()
                {
                    NoteId = note.NoteId,
                    Description = note.Description,
                    NoteText = note.NoteText,
                });
            }
        }
示例#8
0
        public void UpdateNote(int noteId, string noteText)
        {
            using(var context = new NotepadDBEntities()) {

                // find the note that matches the noteID and update its content
                var note = context.Notes.Where(n => n.NoteId.Equals(noteId)).Single();
                note.NoteText = noteText;
                context.SaveChanges();
            }
        }