// GET: Borrow public ActionResult Index() { var borrows = _borrowRepository.GetBorrowsList(); var mapper = new BorrowMapper(); var transactionList = mapper.MapBorrowTransactionList(borrows); return View(transactionList); }
public ActionResult Create(BorrowViewModel borrowViewModel) { if (borrowViewModel.PersonId == 0) ModelState.AddModelError("PersonFieldCannotBeNull", "Please Select a Person"); if (borrowViewModel.ItemId == 0) ModelState.AddModelError("ItemFieldCannotBeNull", "Please Select an Item"); if (IsItemOnLoan(borrowViewModel.ItemId)) { ModelState.AddModelError("ItemCannotBeBorrowed", "Sorry item is currently on loan."); } if (!ModelState.IsValid) { SetBorrowViewModelSelectListItems(borrowViewModel); return View(borrowViewModel); } var mapper = new BorrowMapper(); var borrowDto = mapper.MapBorrowDto(borrowViewModel); _borrowRepository.Add(borrowDto); return RedirectToAction("Index"); }