public void DeleteNote(Note note) { var existing = db.notes.Single(x => x.Id == note.Id); if (existing != null) { db.notes.DeleteOnSubmit(existing); db.SubmitChanges(); } }
public void UpdateNote(Note note) { Note noteToUpdate = db.notes.Where(x => x.Id == note.Id).First(); noteToUpdate.Message = note.Message; noteToUpdate.PointOfInterest = note.PointOfInterest; noteToUpdate.Title = note.Title; try { db.SubmitChanges(); } catch (Exception e) { Console.WriteLine("Error while trying to save a note : " + e); } }
private void Init(int trip, int note, PointOfInterest poi, Mode mode) { this.Mode = mode; if (this.Mode == ViewModels.Mode.add) { Note = new Note(); DataServiceTrip dsTrip = new DataServiceTrip(); Note.Trip = dsTrip.getTripById(trip); Note.Date = DateTime.Now; if (poi != null) this.POISelected = poi; } else { Note = GetNoteInDB(note); } if (Note.Trip.PointsOfInterests != null) _poiList = new List<PointOfInterest>(Note.Trip.PointsOfInterests); EditableObject = new Caretaker<Note>(this.Note); EditableObject.BeginEdit(); InitialiseValidator(); }
public void addNote(Note newNote) { db.notes.InsertOnSubmit(newNote); db.SubmitChanges(); }