// GET: api/Note public IEnumerable <Notes> Get(int owner) { CheckCallerId(); using (var context = new RetroContext.RetroDataContext()) { context.DeferredLoadingEnabled = false; IEnumerable <Notes> ownersnotes = from note in context.Notes where note.CreatedBy == owner select note; return(ownersnotes.ToList()); } }
// GET: api/Note/5 public Notes GetById(int owner, int id) { CheckCallerId(); using (var context = new RetroContext.RetroDataContext()) { var ownersnotes = from note in context.Notes where note.CreatedBy == owner && note.Id == id select note; return(ownersnotes.First()); } }
// put: api/Note public void Put(Notes note) { CheckCallerId(); using (var context = new RetroContext.RetroDataContext()) { Notes xnote = context.Notes.First(a => (a.CreatedBy == note.CreatedBy) && a.Id == note.Id); if (note != null && xnote != null) { xnote.Note = note.Note; } context.SubmitChanges(); } }
// DELETE: api/Note/5 public void Delete(int owner, int id) { CheckCallerId(); using (var context = new RetroContext.RetroDataContext()) { Notes note = context.Notes.First(a => (a.CreatedBy == owner) && a.Id == id); if (note != null) { context.Notes.DeleteOnSubmit(note); } context.SubmitChanges(); } }
// post: api/Note public void post(Notes note) { CheckCallerId(); using (var context = new RetroContext.RetroDataContext()) { context.Notes.InsertOnSubmit(note); try { context.SubmitChanges(); } catch (Exception) { //log context.SubmitChanges(); } } }