Esempio n. 1
0
        public IHttpActionResult PostPerson(Person person)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            //db.People.Add(person);
            //db.SaveChanges();
            _genericService.AddOrUpdate<Person>(person);

            return CreatedAtRoute("DefaultApi", new { id = person.Id }, person);
        }
Esempio n. 2
0
        public IHttpActionResult PutPerson(int id, Person person)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

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

            if (! _genericService.Exists<Person>(id))
            {
                return NotFound();
            }
            else
            {
                _genericService.AddOrUpdate<Person>(person);
            }

            return StatusCode(HttpStatusCode.NoContent);
        }