Esempio n. 1
0
        public IHttpActionResult PostSystem(StatusPage.Data.Models.System system)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Systems.Add(system);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (SystemExists(system.ID))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = system.ID }, system));
        }
Esempio n. 2
0
        public IHttpActionResult PutSystem(Guid id, StatusPage.Data.Models.System system)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != system.ID)
            {
                return(BadRequest());
            }

            db.Entry(system).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SystemExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 3
0
        public IHttpActionResult GetSystem(Guid id)
        {
            StatusPage.Data.Models.System system = db.Systems.Find(id);
            if (system == null)
            {
                return(NotFound());
            }

            return(Ok(system));
        }
Esempio n. 4
0
        public IHttpActionResult DeleteSystem(Guid id)
        {
            StatusPage.Data.Models.System system = db.Systems.Find(id);
            if (system == null)
            {
                return(NotFound());
            }

            db.Systems.Remove(system);
            db.SaveChanges();

            return(Ok(system));
        }