protected void Page_PreRender(object sender, EventArgs e) { //GET ANY MESSAGES FROM SESSION IList <string> sessionMessages = Session["BasketMessage"] as IList <string>; //GET THE BASKET AND RECALCULATE Basket basket = AbleContext.Current.User.Basket; IBasketService preCheckoutService = AbleContext.Resolve <IBasketService>(); preCheckoutService.Recalculate(basket); foreach (var rec in basket.Items) { rec.Price = Math.Abs(rec.Price); } //VALIDATE THE BASKET ValidationResponse response = preCheckoutService.Validate(basket); //DISPLAY ANY WARNING MESSAGES if ((!response.Success) || (sessionMessages != null)) { if (sessionMessages != null) { Session.Remove("BasketMessage"); sessionMessages.AddRange(response.WarningMessages); WarningMessageList.DataSource = sessionMessages; } else { WarningMessageList.DataSource = response.WarningMessages; } WarningMessageList.DataBind(); } BindBasketGrid(); }
private bool CreateAccount() { // NEED TO REGISTER USER if (AbleContext.Current.User.IsAnonymous) { // VALIDATE EMAIL, IF EMAIL IS ALREADY REGISTERED, ASK FOR LOGIN string newEmail = StringHelper.StripHtml(Email.Text); if (UserDataSource.IsEmailRegistered(newEmail)) { IList <string> warningMessages = new List <string>(); warningMessages.Add("The email address you have provided is already registered.Please sign in to access your account."); WarningMessageList.DataSource = warningMessages; WarningMessageList.DataBind(); return(false); } // ANONYMOUS USER SELECTING GUEST CHECKOUT, CREATE TEMPORARY ACCOUNT User oldUser = AbleContext.Current.User; string newUserName = "******" + Guid.NewGuid().ToString("N") + "@domain.xyz"; string newPassword = Guid.NewGuid().ToString("N"); MembershipCreateStatus createStatus; User newUser = UserDataSource.CreateUser(newUserName, newEmail, newPassword, string.Empty, string.Empty, true, 0, out createStatus); // IF THE CREATE FAILS, IGNORE AND CONTINUE CREATING THE ORDER if (createStatus == MembershipCreateStatus.Success) { // CHANGE THE NAME AND EMAIL TO SOMETHING MORE FRIENDLY THAN GUID newUser.UserName = "******" + newUser.Id.ToString() + "@domain.xyz"; newUser.PrimaryAddress.Email = newEmail; newUser.PrimaryAddress.CountryCode = AbleContext.Current.Store.DefaultWarehouse.CountryCode; newUser.PrimaryAddress.IsBilling = true; newUser.PrimaryAddress.Residence = true; newUser.Save(); CommerceBuilder.Users.User.Migrate(oldUser, newUser, true, true); AbleContext.Current.User = newUser; FormsAuthentication.SetAuthCookie(newUser.UserName, false); } } return(true); }
protected void Page_Load(object sender, EventArgs e) { // VALIDATE THE WISHLIST Wishlist wishlist = AbleContext.Current.User.PrimaryWishlist; List <string> warnMessages; bool isValid = wishlist.Validate(out warnMessages); // DISPLAY ANY WARNING MESSAGES if (!isValid) { WarningMessageList.DataSource = warnMessages; WarningMessageList.DataBind(); } // INITIALIZE PASSWORD ON FIRST VISIT if (!Page.IsPostBack) { WishlistPasswordValue.Text = wishlist.ViewPassword; } //TOGGLE PRICE COLUMNS _ItemPrice = WishlistGrid.Columns[2]; _ItemPrice.Visible = !AnyWishlistItemsZero(); }