public async Task <IHttpActionResult> PutOpenHouse(int id, OpenHouse openHouse) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != openHouse.OpenHouseId) { return(BadRequest()); } //openHouse.OpenHouseCreatedDateTime = DateTime.Now; openHouse.OpenHouseLastUpdatedDateTime = DateTime.Now; db.Entry(openHouse).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OpenHouseExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> PutListing(int id, Listing listing) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != listing.ListingId) { return(BadRequest()); } //listing.ListingCreatedDateTime = DateTime.Now; listing.ListingLastUpdatedDateTime = DateTime.Now; db.Entry(listing).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ListingExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> PutAgent(int id, Agent agent) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != agent.AgentId) { return(BadRequest()); } //db.context.Set<TEntity>().Attach(entity); //attach //agent.AgentCreatedDateTime = DateTime.Now; agent.AgentLastUpdatedDateTime = DateTime.Now; db.Entry(agent).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AgentExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }