/// <summary> /// Sets the fields to their proper values. /// </summary> /// <param name="returnedLoan"></param> /// <param name="returnedLoanService"></param> public AboutHistoryForm(ReturnedLoan returnedLoan, ReturnedLoanService returnedLoanService) { RLS = returnedLoanService; RL = returnedLoan; InitializeComponent(); lbl_BookTitle.Text = RL.BookCopy.Book.Title; txt_TimeOfLoan.Text = RL.TimeOfLoan.ToString(); txt_TimeOfReturn.Text = RL.TimeOfReturn.ToString(); }
private void CreateReturnedLoan(Loan loan) { ReturnedLoan returned = new ReturnedLoan() { BookCopy = loan.BookCopy as BookCopy, TimeOfLoan = loan.TimeOfLoan, TimeOfReturn = loan.TimeOfReturn, Member = loan.Member as Member, DueDate = loan.DueDate }; _returnedLoanService.Add(returned); }
public IActionResult ReturnLoan(string id, [FromBody] ReturnedLoan loan) { var returnedLoan = db.Loans.SingleOrDefault(r => r.Id.ToString() == id); if (returnedLoan == null) { return(NotFound()); } else if (ModelState.IsValid) { returnedLoan.Active = false; returnedLoan.ReturnDate = DateTime.Now; db.Loans.Update(returnedLoan); var returnedItem = db.Item.FirstOrDefault(i => i.Id.Equals(returnedLoan.ItemId)); returnedItem.IsAvailable = true; db.SaveChanges(); return(Ok(returnedLoan)); } else { return(BadRequest()); } }
/// <summary> /// Adds a returned loan to the database /// </summary> /// <param name="returnedLoan">The returned loan to add to the database</param> public void Add(ReturnedLoan returnedLoan) { returnedLoanRepository.Add(returnedLoan); }