public async Task <IHttpActionResult> PutRentState(int id, RentState rentState) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != rentState.RentStateId) { return(BadRequest()); } db.Entry(rentState).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RentStateExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public void CheckForOverdue() { if ((this.rentState == RentState.Taken) && (this.deadLine < DateTime.Now)) { this.rentState = RentState.Overdue; } }
public async Task <IHttpActionResult> GetRentState(int id) { RentState rentState = await db.RentStates.FindAsync(id); if (rentState == null) { return(NotFound()); } return(Ok(rentState)); }
public async Task <IHttpActionResult> PostRentState(RentState rentState) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.RentStates.Add(rentState); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = rentState.RentStateId }, rentState)); }
public async Task <IHttpActionResult> DeleteRentState(int id) { RentState rentState = await db.RentStates.FindAsync(id); if (rentState == null) { return(NotFound()); } db.RentStates.Remove(rentState); await db.SaveChangesAsync(); return(Ok(rentState)); }
public Task <bool> Update(RentState entity) { throw new System.NotImplementedException(); }
public void ReturnRentedItem() { this.dateOfReturn = DateTime.Now; this.rentState = RentState.Returned; }