Esempio n. 1
0
        public IHttpActionResult PutDigitalIds(int id, DigitalIds digitalIds)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

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

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

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

            return StatusCode(HttpStatusCode.NoContent);
        }
Esempio n. 2
0
        public IHttpActionResult PostDigitalIds(DigitalIds digitalIds)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.DigitalIds.Add(digitalIds);
            db.SaveChanges();

            return CreatedAtRoute("DefaultApi", new { id = digitalIds.ID }, digitalIds);
        }