Esempio n. 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;
            }
        }
Esempio n. 2
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,
                };
            }
        }
 /// <summary>
 /// Create a new Note object.
 /// </summary>
 /// <param name="noteId">Initial value of the NoteId property.</param>
 /// <param name="userId">Initial value of the UserId property.</param>
 /// <param name="noteText">Initial value of the NoteText property.</param>
 /// <param name="description">Initial value of the Description property.</param>
 public static Note CreateNote(global::System.Int32 noteId, global::System.Guid userId, global::System.String noteText, global::System.String description)
 {
     Note note = new Note();
     note.NoteId = noteId;
     note.UserId = userId;
     note.NoteText = noteText;
     note.Description = description;
     return note;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Notes EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToNotes(Note note)
 {
     base.AddObject("Notes", note);
 }