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)); } }
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")); }
public void Initial() { cartApp = new CartAppService(); }