Exemplo n.º 1
0
        public IHttpActionResult PutAuthorization(int id, GeniusBar.Models.Authorization authorization)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 2
0
        public IHttpActionResult GetAuthorization(int id)
        {
            GeniusBar.Models.Authorization authorization = db.Authorizations.Find(id);
            if (authorization == null)
            {
                return(NotFound());
            }

            return(Ok(authorization));
        }
Exemplo n.º 3
0
        public IHttpActionResult PostAuthorization(GeniusBar.Models.Authorization authorization)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Authorizations.Add(authorization);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = authorization.ID }, authorization));
        }
Exemplo n.º 4
0
        public IHttpActionResult DeleteAuthorization(int id)
        {
            GeniusBar.Models.Authorization authorization = db.Authorizations.Find(id);
            if (authorization == null)
            {
                return(NotFound());
            }

            db.Authorizations.Remove(authorization);
            db.SaveChanges();

            return(Ok(authorization));
        }