public ActionResult Injected() { var person = new Person { Name = "John Doe", BirthDate = new DateTime(1980, 1, 1), State = StatesService.GetStates()[1] }; return(View(person)); }
public async Task <ActionResult> SavePersonalInfo(Customer customer) { customer.PaymentMethodCode = "X"; customer.CardNo = "X"; customer.ExpDate = DateTime.Now.AddMonths(12); SetStates(); if (ModelState.IsValid) { var c = new Customer { FName = customer.FName, LName = customer.LName, Email = Request.Cookies["User"] == null ? customer.Email : Request.Cookies["User"]["Email"], Phone = customer.Phone, Address1 = customer.Address1, Address2 = customer.Address2, Postcode = customer.Postcode, State = customer.State, PaymentMethodCode = "x", CardNo = "xxxxxxxxxxxxxxxx", ExpDate = customer.ExpDate }; var customerService = new CustomerService(); customerService.SavePersonalInfo(c, Session.SessionID); return(View("AccountConfirmation")); } else { ViewBag.States = StatesService.GetStates(); } List <ModelError> errors = new List <ModelError>(); foreach (ModelState modelState in ViewData.ModelState.Values) { foreach (ModelError error in modelState.Errors) { errors.Add(error); } } return(View("PersonalInfo", customer)); }
private void SetStates() { ViewBag.States = StatesService.GetStates(); }
protected override object WithValue(PropertyInfo propertyInfo) { return(StatesService.GetStates()); }
public CheckoutController() { states = StatesService.GetStates(); }