示例#1
0
        public ActionResult Register(RegisterViewModel user)
        {
            if (ModelState.IsValid == false)
            {
                return(View(user));
            }
            IdentityResult result = accountAppService.Register(user);

            if (result.Succeeded)
            {
                CartAppService         cartAppService = new CartAppService();
                IAuthenticationManager owinMAnager    = HttpContext.GetOwinContext().Authentication;
                //SignIn
                SignInManager <ApplicationUserIdentity, string> signinmanager =
                    new SignInManager <ApplicationUserIdentity, string>(
                        new ApplicationUserManager(), owinMAnager
                        );
                ApplicationUserIdentity identityUser = accountAppService.Find(user.UserName, user.PasswordHash);
                signinmanager.SignIn(identityUser, true, true);

                /*
                 * var userSignIn = User.Identity.GetUserId();
                 * cartAppService.InsertCart(userSignIn);
                 */
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                ModelState.AddModelError("", result.Errors.FirstOrDefault());
                return(View(user));
            }
        }
示例#2
0
        public ActionResult Create(string cartId)
        {
            CartAppService        cartAppService = new CartAppService();
            ProductCartAppService productCartApp = new ProductCartAppService();
            Cart cart = cartAppService.GetById(cartId);

            orderAppServices.InsertProductToOrder(cart);
            //cartAppService.Delete(cart.User_Id);
            foreach (var item in cart.ProductsCart)
            {
                productCartApp.DeleteProductCart(item.Id);
            }

            return(RedirectToAction("Index", "cart"));
        }
示例#3
0
 public void Initial()
 {
     cartApp = new CartAppService();
 }