public async Task <ActionResult> Register(RegisterViewModel model) { PrimeMarketEntities db = new PrimeMarketEntities(); if (ModelState.IsValid) { var user = new ApplicationUser { UserName = model.Email, Email = model.Email, FullName = model.FullName }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); //var callbackUrl = Url.Action("ConfirmEmail", "Account", new { email = model.Email, code = code }, protocol: Request.Url.Scheme); //*await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"); string EmailBody = "Please confirm your account by clicking on following link " + callbackUrl; Helper.SendMail(model.Email, "Confirm your account", EmailBody); //*return RedirectToAction("Index", "Home"); return(RedirectToAction("RegisterConfirmation_moh", "Account")); } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }
public static void ClearCart() { PrimeMarketEntities context = new PrimeMarketEntities(); var CustomerId = System.Web.HttpContext.Current.User.Identity.GetUserId(); try { var cart = context.Carts.RemoveRange(context.Carts.Where(c => c.CustomerId == CustomerId).ToList()); context.SaveChanges(); } catch { } }
public static double getCartTotal() { double total = 0; PrimeMarketEntities context = new PrimeMarketEntities(); var CustomerId = System.Web.HttpContext.Current.User.Identity.GetUserId(); try { var cart = context.Carts.Where(c => c.CustomerId == CustomerId).ToList(); foreach (var item in cart) { total += (double)item.Commodity.Price * (double)item.Quantity; } } catch { } return(total); }