示例#1
0
        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));
        }
示例#2
0
 public void CheckForOverdue()
 {
     if ((this.rentState == RentState.Taken) && (this.deadLine < DateTime.Now))
     {
         this.rentState = RentState.Overdue;
     }
 }
示例#3
0
        public async Task <IHttpActionResult> GetRentState(int id)
        {
            RentState rentState = await db.RentStates.FindAsync(id);

            if (rentState == null)
            {
                return(NotFound());
            }

            return(Ok(rentState));
        }
示例#4
0
        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));
        }
示例#5
0
        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();
 }
示例#7
0
 public void ReturnRentedItem()
 {
     this.dateOfReturn = DateTime.Now;
     this.rentState    = RentState.Returned;
 }