public HouseEntity Update(HouseEntity toUpdate) { HouseEntity single = _context.Houses.FirstOrDefault(x => x.Id == toUpdate.Id); if (single == null) { return null; } _context.Houses.AddOrUpdate(toUpdate); return toUpdate; }
public IHttpActionResult CreateNewHouse(HouseEntity houseEntity) { if (!ModelState.IsValid) { return BadRequest(ModelState); } HouseEntity addedEntity = _houseRepository.Add(houseEntity); _houseRepository.SaveToDb(); return Created(addedEntity); }
public HouseEntity Add(HouseEntity toAdd) { _context.Houses.Add(toAdd); return toAdd; }
public IHttpActionResult UpdateFullHouse([FromODataUri] int id, HouseEntity houseEntity) { if (!ModelState.IsValid) { return BadRequest(ModelState); } HouseEntity existingHouseEntity = _houseRepository.GetSingle(id).First(); if (existingHouseEntity == null) { return NotFound(); } houseEntity.Id = existingHouseEntity.Id; _houseRepository.Update(houseEntity); _houseRepository.SaveToDb(); return StatusCode(HttpStatusCode.NoContent); }