// GET: /<controller>/Create public IActionResult Create(PaymentRequestCreateViewmodel viewmodel) { List <Person> persons = _personRetRepository.GetAllActive(); List <Product> products = new List <Product>(); if (HttpContext.Session.GetComplexData <List <Product> >("productList") != null) { viewmodel.ProductOverview = HttpContext.Session.GetComplexData <List <Product> >("productList"); } else { products = _productRetRepository.GetAll(); HttpContext.Session.SetComplexData("productList", products); } int personenIndex; if (HttpContext.Session.GetInt32("personenIndex") == null) { HttpContext.Session.SetInt32("personenIndex", 0); personenIndex = 0; } else { personenIndex = (int)HttpContext.Session.GetInt32("personenIndex"); } if (viewmodel.ProductOverview.Count == 0) { viewmodel = new PaymentRequestCreateViewmodel(personenIndex, products, persons); } if (persons.Count > viewmodel.PersonIndex) { Person person = persons[viewmodel.PersonIndex]; PaymentRequest model = new PaymentRequest(person, viewmodel.ProductOverview); viewmodel.SetModel(model); return(View(viewmodel)); } else { HttpContext.Session.Remove("personenIndex"); HttpContext.Session.Remove("productList"); return(RedirectToAction("Index", "Home")); } }
// GET: /<controller>/ public IActionResult Index() { var viewModel = new PersonListViewModel(); viewModel.Persons = _personRetRepository.GetAllActive(); return(View(viewModel)); }