public ActionResult ConfirmCustomerDetails() { OrderCheckoutView orderCheckoutView = (OrderCheckoutView)TempData["orderCheckoutView"]; _isInfoValid = ""; ViewBag.Message = _isInfoValid; return(View(orderCheckoutView)); //new customer view }
public ActionResult ConfirmCustomerDetails(Customer customer, int?customerId, int movieId, Address address) { if (ModelState.IsValid) { if (customerId != null) { _om.Create(new Order() { CustomerId = customerId.Value, MovieId = movieId, Date = DateTime.Now }); Address addressToUpdate = _am.Read(customerId.Value); addressToUpdate = address; addressToUpdate.Id = customerId.Value; _am.Update(addressToUpdate); Customer custmerToUpdate = _cm.Read(customerId.Value); custmerToUpdate = customer; custmerToUpdate.Id = customerId.Value; _cm.Update(custmerToUpdate); return(RedirectToAction("ConfirmationView")); } _cm.Create(new Customer() { Address = address, Email = customer.Email, FirstName = customer.FirstName, LastName = customer.LastName }); Customer orderingCustomer = _cm.Read().FirstOrDefault(x => x.Email == customer.Email); _om.Create(new Order() { CustomerId = orderingCustomer.Id, MovieId = movieId, Date = DateTime.Now }); return(RedirectToAction("ConfirmationView")); } TempData["RedirectedUserInfo"] = true; var customers = _cm.Read(); var customerFound = customers.FirstOrDefault(x => x.Email == customer.Email); Movie movie = _mm.Read(movieId); var ocv = new OrderCheckoutView() { Customer = customerFound, Movie = movie, Email = customer.Email }; _isInfoValid = "Invalid data."; ViewBag.Message = _isInfoValid; return(View(ocv)); }
public ActionResult CheckEmail(string email, int movieId) { if (ModelState.IsValid && IsValidEmail(email)) { var customers = _cm.Read(); var customerFound = customers.FirstOrDefault(x => x.Email == email); Movie movie = _mm.Read(movieId); var orderCheckoutView = new OrderCheckoutView() { Customer = customerFound, Movie = movie, Email = email }; TempData["orderCheckoutView"] = orderCheckoutView; return(RedirectToAction("ConfirmCustomerDetails")); //new customer view } //Movie m = _mm.Read(movieId); TempData["RedirectedEmail"] = true; return(RedirectToAction("CheckEmail", new { Id = movieId })); }