//This Action is called from the initial shopping cart page //The user will click this when they are ready to purchase their products //It will return 1 of 2 views, depending on the users' login status public IActionResult PaymentAuthentication(string orders) { //First check if there are any orders. If not, nothing should happen. Refresh the page if (orders == null) { return(RedirectToAction("ShoppingCart", "ShoppingCart")); } //Retrieve the user status to check whether the user is logged in or not UserStatusModel userStatus = SessionController.CheckLoggedInStatus(this.HttpContext); //Put the orders in the browser session. This refreshes the list, so if the user has altered their shopping cart, it'll always be up to date when entering the ordering sequence SessionController.refreshOrderList(orders, this.HttpContext); if (userStatus.LoggedIn) { //User is logged in already, so return the PaymentMethod view List <OfferedLabourerService> olsList = ParseOrdersToOLS(); tbl_userdata user = MollShopContext.FindUserById((int)this.HttpContext.Session.GetInt32("UserId")); Tuple <List <OfferedLabourerService>, tbl_userdata> tuple = Tuple.Create(olsList, user); return(View("OrderSpecification", tuple)); } else { //User is not logged in. return the PaymentAuthentication view return(View()); } }
//Pagina voor My Account public IActionResult MyAccount() { //Vraag de useraccount op met een procedure //Get User ID from the browser session int?userId = HttpContext.Session.GetInt32("UserId"); if (userId == null) { return(RedirectToAction("Login", "Page", new LoginModel())); } tbl_userdata foundUser = MollShopContext.FindUserById((int)userId); return(View(foundUser)); }
//This action does the authentication for registered users that are about to make a purchase public IActionResult DoAuthentication(string fld_emailaddress, string fld_password) { LoginModel loginMdl = new LoginModel(fld_emailaddress, fld_password); loginMdl = DatabaseController.Login(loginMdl, this.HttpContext); ViewBag.Message = loginMdl.Message; if (loginMdl.UserId <= 0) { return(View("PaymentAuthentication", this.HttpContext.Session.GetString("ORD"))); } else { this.HttpContext.Session.SetString("OrderMail", loginMdl.EmailAddress); tbl_userdata user = MollShopContext.FindUserById(loginMdl.UserId); return(RedirectToAction("OrderSpecification", user)); } }