Example #1
0
        // PUT api/GroupAnimationType/5
        public HttpResponseMessage PutGroupAnimationType(int id, GroupAnimationType groupanimationtype)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }

            if (id != groupanimationtype.ID)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }

            db.GroupAnimationTypes.Attach(groupanimationtype);
            db.ObjectStateManager.ChangeObjectState(groupanimationtype, EntityState.Modified);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.NotFound, ex));
            }

            return(Request.CreateResponse(HttpStatusCode.OK));
        }
Example #2
0
        // GET api/GroupAnimationType/5
        public GroupAnimationType GetGroupAnimationType(int id)
        {
            GroupAnimationType groupanimationtype = db.GroupAnimationTypes.Single(g => g.ID == id);

            if (groupanimationtype == null)
            {
                throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            return(groupanimationtype);
        }
Example #3
0
        // POST api/GroupAnimationType
        public HttpResponseMessage PostGroupAnimationType(GroupAnimationType groupanimationtype)
        {
            if (ModelState.IsValid)
            {
                db.GroupAnimationTypes.AddObject(groupanimationtype);
                db.SaveChanges();

                HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, groupanimationtype);
                response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = groupanimationtype.ID }));
                return(response);
            }
            else
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }
        }
Example #4
0
        // DELETE api/GroupAnimationType/5
        public HttpResponseMessage DeleteGroupAnimationType(int id)
        {
            GroupAnimationType groupanimationtype = db.GroupAnimationTypes.Single(g => g.ID == id);

            if (groupanimationtype == null)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            db.GroupAnimationTypes.DeleteObject(groupanimationtype);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.NotFound, ex));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, groupanimationtype));
        }