Ejemplo n.º 1
0
 public void DeleteNote(int noteId)
 {
     using (var context = new MiniCMSEntities())
     {
         var note = GetNoteInternal(noteId, context);
         context.Notes.Remove(note);
         context.SaveChanges();
     }
 }
Ejemplo n.º 2
0
        public int AddNote(Notes note)
        {
            using (var context = new MiniCMSEntities())
            {
                if (IsExistName(note.Name, context))
                    throw new InvalidOperationException("This name is already used");

                context.Notes.Add(note);
                context.SaveChanges();

                return note.Id;
            }
        }
Ejemplo n.º 3
0
        public void ChangeNote(int noteId, string noteName, string htmlContent, string shortNote)
        {
            using (var context = new MiniCMSEntities())
            {
                var note = GetNoteInternal(noteId, context);

                if (note.Name != noteName)
                {
                    if (IsExistName(noteName, context))
                        throw new InvalidOperationException("This name is already used");
                }

                note.Name = noteName;
                note.HTML = htmlContent;
                note.ShortNote = shortNote;

                context.SaveChanges();
            }
        }