public void AdicionarNota(NotesSet note) { using (var conexao = new NoteAppContext()) { conexao.Note.Add(note); conexao.SaveChanges(); } }
private void btn_Add_Click(object sender, EventArgs e) { var note = new NotesSet { CH_Name = tb_Nome.Text, CH_Description = tb_Description.Text, DT_Creation = DateTime.Now }; new NotesController().AdicionarNota(note); Close(); }
public void RemoverNota(int id) { using (var conexao = new NoteAppContext()) { var note = new NotesSet { ID = id }; conexao.Note.Attach(note); conexao.Note.Remove(note); conexao.SaveChanges(); } }
public void AtualizarNote(NotesSet note) { using (var conexao = new NoteAppContext()) { var result = conexao.Note.SingleOrDefault(b => b.ID == note.ID); if (result != null) { result.CH_Name = note.CH_Name; result.CH_Description = note.CH_Description; result.DT_Creation = note.DT_Creation; conexao.SaveChanges(); } } }