public async Task<IHttpActionResult> PutAppartmentType(int id, AppartmentType appartmentType) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != appartmentType.Id) { return BadRequest(); } db.Entry(appartmentType).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AppartmentTypeExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostAppartmentType(AppartmentType appartmentType) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.AppartmentTypes.Add(appartmentType); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = appartmentType.Id }, appartmentType); }