public PersonEntity Update(PersonEntity toUpdate) { PersonEntity single = _context.Persons.FirstOrDefault(x => x.Id == toUpdate.Id); if (single == null) { return null; } _context.Persons.AddOrUpdate(toUpdate); return toUpdate; }
public IHttpActionResult CreateNewPerson(PersonEntity personEntity) { if (!ModelState.IsValid) { return BadRequest(ModelState); } PersonEntity addedEntity = _personRepository.Add(personEntity); _personRepository.SaveToDb(); return Created(addedEntity); }
public PersonEntity Add(PersonEntity toAdd) { _context.Persons.Add(toAdd); return toAdd; }
public IHttpActionResult UpdateFullPerson([FromODataUri] int id, PersonEntity personEntity) { if (!ModelState.IsValid) { return BadRequest(ModelState); } PersonEntity existingPersonEntity = _personRepository.GetSingle(id).First(); if (existingPersonEntity == null) { return NotFound(); } personEntity.Id = existingPersonEntity.Id; _personRepository.Update(personEntity); _personRepository.SaveToDb(); return StatusCode(HttpStatusCode.NoContent); }