Ejemplo n.º 1
0
        // POST api/AppUserLoyalty
        public HttpResponseMessage PostAppUserLoyalty(AppUserLoyalty appuserloyalty)
        {
            if (ModelState.IsValid)
            {
                db.AppUserLoyalties.Add(appuserloyalty);
                db.SaveChanges();

                HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, appuserloyalty);
                response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = appuserloyalty.AppUserLoyaltyId }));
                return response;
            }
            else
            {
                return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
            }
        }
Ejemplo n.º 2
0
        // PUT api/AppUserLoyalty/5
        public HttpResponseMessage PutAppUserLoyalty(Guid id, AppUserLoyalty appuserloyalty)
        {
            if (!ModelState.IsValid)
            {
                return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
            }

            if (id != appuserloyalty.AppUserLoyaltyId)
            {
                return Request.CreateResponse(HttpStatusCode.BadRequest);
            }

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

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

            return Request.CreateResponse(HttpStatusCode.OK);
        }