예제 #1
0
        public IHttpActionResult Post(File file)
        {
            var db = new FilesContext();

            db.Files.Add(file);
            db.SaveChanges();

            return(Created(file));
        }
예제 #2
0
        public IHttpActionResult Get([FromODataUri] int key)
        {
            var  db   = new FilesContext();
            File file = db.Files.FirstOrDefault(c => c.FileId == key);

            if (file == null)
            {
                return(NotFound());
            }
            return(Ok(file));
        }
예제 #3
0
        public IHttpActionResult Delete(int key)
        {
            var  db       = new FilesContext();
            File original = db.Files.FirstOrDefault(c => c.FileId == key);

            if (original == null)
            {
                return(NotFound());
            }

            db.Files.Remove(original);
            db.SaveChanges();

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #4
0
        public IHttpActionResult Patch(int key, Delta <File> patch)
        {
            var db   = new FilesContext();
            var file = db.Files.SingleOrDefault(c => c.FileId == key);

            if (file == null)
            {
                return(NotFound());
            }

            patch.Patch(file);
            db.SaveChanges();

            return(Updated(file));
        }
예제 #5
0
        public IQueryable <File> Get()
        {
            var db = new FilesContext();

            return(db.Files);
        }