public IActionResult Next(PaymentRequestCreateViewmodel viewmodel) //Save and to next person { //save info if (HttpContext.Session.GetInt32("personenIndex") != null) { viewmodel.PersonIndex = (int)HttpContext.Session.GetInt32("personenIndex"); } viewmodel.NextIndex(); HttpContext.Session.SetInt32("personenIndex", viewmodel.PersonIndex); return(RedirectToAction("Create", viewmodel)); }
// 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")); } }
public IActionResult Skip(PaymentRequestCreateViewmodel viewmodel) //Put person as Inactive and to next person { Person person = new Person(); if (HttpContext.Session.GetInt32("personenIndex") != null) { List <Person> persons = _personRetRepository.GetAllActive(); viewmodel.PersonIndex = (int)HttpContext.Session.GetInt32("personenIndex"); person = persons[viewmodel.PersonIndex]; } if (person.BonNr != null) { person.changeActivity(); _personSaveRepository.UpdatePerson(person); } viewmodel.NextIndex(); HttpContext.Session.SetInt32("personenIndex", viewmodel.PersonIndex); return(RedirectToAction("Create", viewmodel)); }