public void DeleteNote(int noteId) { using (var context = new MiniCMSEntities()) { var note = GetNoteInternal(noteId, context); context.Notes.Remove(note); context.SaveChanges(); } }
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; } }
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(); } }