コード例 #1
0
        public IHttpActionResult PutPushRegistrations(int id, PushRegistrations pushRegistrations)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

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

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

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

            return StatusCode(HttpStatusCode.NoContent);
        }
コード例 #2
0
        public IHttpActionResult PostPushRegistrations(PushRegistrations pushRegistrations)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            else if (db.PushRegistrations.Any(r => r.TripUserId == pushRegistrations.TripUserId && r.RegistrationId == pushRegistrations.RegistrationId))
            {
                return null;
            }

            db.PushRegistrations.Add(pushRegistrations);
            db.SaveChanges();

            return CreatedAtRoute("DefaultApi", new { id = pushRegistrations.Id }, pushRegistrations);
        }