Beispiel #1
0
        public IActionResult Confirmed(AccountMyProfileEditVM account)
        {
            MyShoppingCartVM myCartVM;

            if (User.Identity.IsAuthenticated)
            {
                string userID     = signInManager.UserManager.GetUserId(HttpContext.User);
                int    customerID = webShopDBContext.User.First(u => u.Uid == userID).Id;
                myCartVM = SessionUtils.GetArticles(this, webShopDBContext);
                webShopDBContext.AddOrder(customerID, myCartVM, webShopDBContext);
            }
            else
            {
                webShopDBContext.User.Add(new User {
                    Firstname   = account.FirstName,
                    Lastname    = account.LastName,
                    Phonenumber = account.PhoneNumber,
                    Email       = account.Email,
                    Addressline = account.AddressLine,
                    Zipcode     = account.ZipCode,
                    City        = account.City
                });
                webShopDBContext.SaveChanges();

                int customerID = webShopDBContext.User.First(u => u.Email == account.Email).Id;
                myCartVM = SessionUtils.GetArticles(this, webShopDBContext);
                webShopDBContext.AddOrder(customerID, myCartVM, webShopDBContext);
            }
            HttpContext.Session.Clear();

            return(View());
        }