Exemple #1
0
 // 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());
     }
 }
Exemple #2
0
        // 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());
            }
        }
Exemple #3
0
        // 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();
            }
        }
Exemple #4
0
        // 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();
            }
        }
Exemple #5
0
        // 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();
                }
            }
        }