Esempio n. 1
0
        public IHttpActionResult PostRadiusEntry(RadiusEntry radiusEntry)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.RadiusEntries.Add(radiusEntry);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (RadiusEntryExists(radiusEntry.id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = radiusEntry.id }, radiusEntry));
        }
Esempio n. 2
0
        public IHttpActionResult PutRadiusEntry(long id, RadiusEntry radiusEntry)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 3
0
        public IHttpActionResult GetRadiusEntry(long id)
        {
            RadiusEntry radiusEntry = db.RadiusEntries.Find(id);

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

            return(Ok(radiusEntry));
        }
Esempio n. 4
0
        public IHttpActionResult DeleteRadiusEntry(long id)
        {
            RadiusEntry radiusEntry = db.RadiusEntries.Find(id);

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

            db.RadiusEntries.Remove(radiusEntry);
            db.SaveChanges();

            return(Ok(radiusEntry));
        }