public IHttpActionResult PutNote(int id, Note note)
        {
            using (var db = new FakeDbCtx())
            {
                var found = db.Notes.FirstOrDefault(n => n.Id == id);
                if (found == null)
                {
                    return(NotFound());
                }
                var errors = new List <string>();
                if (note.Id < 0)
                {
                    errors.Add("Id cannot be less than 0");
                }
                if (string.IsNullOrEmpty(note.Title))
                {
                    errors.Add("Title cannot be empty");
                }
                if (errors.Any())
                {
                    return(new GlogErrorsResult(errors));
                }
                // set new values to Entity
                found.Title       = note.Title;
                found.Description = note.Description;

                // send updated Entity to DB
//                db.Entry(course).State = EntityState.Modified;
//                db.SaveChanges();

                return(Ok(found));
            }
        }
 public IEnumerable <Note> GetAllNotes(int pageNum = 0, int pageSize = 25)
 {
     using (var db = new FakeDbCtx())
     {
         return(db.Notes.Skip(pageNum * pageSize).Take(pageSize).ToList());
     }
 }
 public IHttpActionResult ByIds(int[] ids)
 {
     using (var db = new FakeDbCtx())
     {
         var filtered = db.Notes.Where(p => ids.Contains(p.Id)).ToList();
         if (filtered.Count == 0)
         {
             return(NotFound());
         }
         return(Ok(filtered));
     }
 }
 public IHttpActionResult GetNote(int id)
 {
     using (var db = new FakeDbCtx())
     {
         var note = db.Notes.FirstOrDefault(p => p.Id == id);
         if (note == null)
         {
             return(NotFound());
         }
         return(Ok(note));
     }
 }