public ActionResult Create(RentBook data) { var listBooks = BookMgr.GetListBook(); var bookOptions = new SelectList(listBooks.Select(org => { return(new SelectListItem { Text = org.BookTitle, Value = org.ID.ToString() }); }), "Value", "Text"); ViewData["BookOptions"] = bookOptions; var book = BookMgr.GetBookByID(data.BookID); data.RentLenght = (data.EndDate - data.StartDate).Days; data.PricePerDay = book.RentPrice; data.UserName = User.Identity.Name; RentMgr.Create(data); ModelState.Clear(); TempData["Message"] = "rent successfully saved"; return(View(data)); }
public ActionResult Create() { RentBook data = new RentBook(); var listBooks = BookMgr.GetListBook(); var bookOptions = new SelectList(listBooks.Select(org => { return(new SelectListItem { Text = org.BookTitle, Value = org.ID.ToString() }); }), "Value", "Text"); ViewData["BookOptions"] = bookOptions; return(View(data)); }