Esempio n. 1
0
        public IHttpActionResult PutGoscie(int id, Goscie goscie)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

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

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

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

            return StatusCode(HttpStatusCode.NoContent);
        }
Esempio n. 2
0
        public IHttpActionResult PostGoscie(Goscie goscie)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.Goscies.Add(goscie);
            db.SaveChanges();

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