// PUT api/Housing/5 public async Task<IHttpActionResult> PutHousing(int id, Housing housing) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != housing.HousingID) { return BadRequest(); } db.Entry(housing).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!HousingExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public int GenerateHousingLocationScore(Housing housing, List<Location> locations) { if ((housing == null) || (locations == null)) { return 0; } var score = GenerateMutuallyPreferredLocationsScore(new List<Location> { housing.Location }, locations); return score; }
public async Task<IHttpActionResult> PostHousing(Housing housing) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Housings.Add(housing); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = housing.HousingID }, housing); }