//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()); } }
public IActionResult ShoppingCart() { List <OfferedLabourerService> serviceList = new List <OfferedLabourerService>(); //Check if we're logged in. bool loggedIn = SessionController.returnLoggedIn(this.HttpContext); if (!loggedIn) { //Not logged in, get products from cookies List <string> keyList = Request.Cookies.Keys.Where(k => k.StartsWith("SC")).ToList(); serviceList = Utility.CookieController.fetchItemsInCookies(keyList); } else { //Logged in, get products from database List <Object> offeredServiceIds = MollShopContext.GetShoppingCartItems((int)HttpContext.Session.GetInt32("UserId")); serviceList = new List <OfferedLabourerService>(); foreach (Object id in offeredServiceIds) { serviceList.Add(ElasticSearch.Queries.EsOLSQuery <object> .findByOfferedServiceId((int)id)); } } PayPalConfig payPalConfig = PayPalService.getPayPalConfig(); ViewBag.payPayConfig = payPalConfig; return(View(serviceList)); }