public void AddNote(Note note) { using (var context = new UchOtdContext(ConnectionString)) { note.NoteId = 0; context.Notes.Add(note); context.SaveChanges(); } }
private void add_Click(object sender, EventArgs e) { if (currentDateTime.Checked) { noteMoment.Value = DateTime.Now; } var newNote = new Note { Text = noteText.Text, Moment = noteMoment.Value, TargetComputer = TargetComputer.Text }; _uoRepo.AddNote(newNote); RefreshView(); }
public static string ViewFromNote(Note note) { return note.Text + "@" + note.Moment.ToString(Format); }
public bool ContainsNote(Note note) { using (var context = new UchOtdContext(ConnectionString)) { return context.Notes.FirstOrDefault(n => n.Moment == note.Moment && n.TargetComputer == note.TargetComputer && n.Text == note.Text) != null; } }
public void UpdateNote(Note note) { using (var context = new UchOtdContext(ConnectionString)) { var curNote = GetNote(note.NoteId); curNote.Text = note.Text; curNote.Moment = note.Moment; curNote.TargetComputer = note.TargetComputer; context.SaveChanges(); } }