public ActionResult CreateRental(int customerId = 0) { ViewBag.CustomerId = customerId; var model = DependencyResolver.Current.GetService <RentalsIndexViewModel>(); model.Rental = /*DependencyResolver.Current.GetService<RentalDTO>();*/ new RentalDTO(); model.Rental.BooksToRent = new List <IBook>(); ViewBag.CustomersDropDown = new SelectList(_rentalServices.PopulateCustomersDropDown(), "Key", "Value"); if (customerId > 0) { model.Rental.Customer = _customerServices.Get(customerId); if (model.Rental.Customer == null) { return(HttpNotFound()); } model.Rental.CustomerId = model.Rental.Customer.Id; model.Rental.CustomerRentalCapacity = _rentalServices.GetCustomerRentalCapacity(model.Rental.Customer); ViewBag.BooksDropDown = new SelectList(_rentalServices.PopulateBooksDropDown(), "Key", "Value"); ViewBag.CustomerId = model.Rental.Customer.Id; ViewBag.CustomerRentalCapacity = model.Rental.CustomerRentalCapacity; } TempData["model"] = model; return(View(model)); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var customer = _customerServices.Get((int)id); if (customer == null) { return(HttpNotFound("Requested customer not found in the database.")); } var model = Mapper.Map <CustomerDTO>(customer); return(View(model)); }