Esempio n. 1
0
        public IHttpActionResult ResetDataSource(String time)
        {
            var dateTime = DateTimeOffset.Parse(time.Replace(' ', '+'));
            var files    = CreateFiles(dateTime);

            _db.Files.RemoveRange(_db.Files);
            _db.SaveChanges();

            _db.Database.Delete();
            _db.Database.Create();

            _db.Files.AddRange(files);
            _db.SaveChanges();

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 2
0
        public IHttpActionResult Post(File file)
        {
            var db = new FilesContext();

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

            return(Created(file));
        }
Esempio n. 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));
        }
Esempio n. 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));
        }