public ActionResult ReturnLoan(LoanViewModel model) { var loan = _loanInformationRepo.GetByID(model.Id); var component = _componentRepo.GetByID(loan.Component.Id); component.LoanerId = null; _componentRepo.SaveChanges(); return RedirectToAction("ShowComponents", "Component"); }
public ActionResult AddLoan(int componentId) { var model = new LoanViewModel { ComponentId = componentId, ReturnDate = GetDefaultReturnDate(), }; return View(model); }
public ActionResult AddLoan(LoanViewModel model) { var loaner = AutoMapper.Mapper.Map<Loaner>(model); var component = _componentRepo.GetByID(model.ComponentId); component.Loaner = loaner; _componentRepo.Update(component); var loanInformation = new LoanInformation { ComponentId = model.ComponentId, IsEmailSent = false, LoanDate = DateTime.UtcNow, ReturnDate = model.ReturnDate, // Not sure what to do with this property, so for now it will be set to UtcNow ReservationDate = DateTime.UtcNow, LoanOwnerId = loaner.Id }; _loanInformationRepo.Insert(loanInformation); return RedirectToAction("ShowComponents", "Component"); }