public async Task <IActionResult> Checkout()
        {
            string sessionKey = MethodHelper.IsThereSomeone(HttpContext.Session);

            userSession = SessionHelper.GetObjectFromJson <UserModel>(HttpContext.Session, "userObject");
            if (userSession != null)
            {
                List <ProductModel> productFromSessionCard = SessionHelper.GetObjectFromJson <List <ProductModel> >(HttpContext.Session, sessionKey);
                StringContent       content       = new StringContent(JsonConvert.SerializeObject(productFromSessionCard), Encoding.UTF8, "application/json");
                CheckoutModel       checkoutModel = JsonConvert.DeserializeObject <CheckoutModel>(await MVCHelper.PostLoginAPI(configuration.GetSection("baseUrl").Value + "api/ProductToCard/" + sessionKey, content));
                HttpContext.Session.Remove("card");
                return(View("Checkout", checkoutModel));
            }
            else
            {
                return(RedirectToAction("Login", "Login"));
            }
        }
コード例 #2
0
        public async Task <IActionResult> LoginSave(LoginModel loginModel)
        {
            StringContent content   = new StringContent(JsonConvert.SerializeObject(loginModel), Encoding.UTF8, "application/json");
            UserModel     userModel = JsonConvert.DeserializeObject <UserModel>(await MVCHelper.PostLoginAPI(string.Format("{0}", configuration.GetSection("baseUrl").Value + "api/LoginSave/"), content));

            if (userModel != null)
            {
                SessionHelper.SetObjectAsJson(HttpContext.Session, "userObject", userModel);
                return(RedirectToAction("Index", "Products"));
            }
            return(RedirectToAction("Index", "Products"));
        }