void gvwSubProfiles_RowCreated(object sender, GridViewRowEventArgs e) { try { if (e.Row.RowType == DataControlRowType.DataRow) { LinkButton lkbDelete = e.Row.Cells[2].Controls.OfType <LinkButton>().SingleOrDefault(a => a.Text == "Deactivate"); if (lkbDelete != null) { lkbDelete.Attributes.Add("onclick", "return confirm('Are you sure that you want to deactivate/reactivate this sub-profile?');"); } hccUserProfile profile = (hccUserProfile)e.Row.DataItem; if (profile != null && !profile.IsActive) { lkbDelete.Text = "Reactivate"; } } } catch (Exception ex) { throw ex; } }
//void chkEditCreditCard_CheckedChanged(object sender, EventArgs e) //{ // if (chkEditCreditCard.Checked) // { // Bind(); // CreditCardDisplay1.Visible = false; // pnlCardInfo.Visible = true; // } // else // { // CreditCardDisplay1.Visible = true; // pnlCardInfo.Visible = false; // } //} protected void cvCardNumCCNumber_ServerValidate(object source, ServerValidateEventArgs args) { cvCardNumCCNumber.ErrorMessage = string.Empty; CurrentCardInfo.CardType = ValidateCardNumber(txtCCNumber.Text.Trim()); if (CurrentCardInfo.CardType == Enums.CreditCardType.Unknown) { args.IsValid = false; cvCardNumCCNumber.ErrorMessage = "Enter a valid card number."; } hccUserProfile prof = hccUserProfile.GetById(CurrentUserProfileID); if (prof != null && !prof.BillingAddressID.HasValue) { args.IsValid = false; if (string.IsNullOrWhiteSpace(cvCardNumCCNumber.ErrorMessage)) { cvCardNumCCNumber.ErrorMessage = "Card requires a billing address."; } else { cvCardNumCCNumber.ErrorMessage += "Card requires a billing address."; } } }
protected void Page_Load(object sender, EventArgs e) { WebpageBase webpageBase = this.Page as WebpageBase; if (null != webpageBase) { _webpage = webpageBase.WebpageInfo; } if (_webpage != null) { PageNameLiteral.Text = _webpage.Text; Page.Title = webpageBase.Title; } lblUserName.Text = ""; lblUserEmail.Text = ""; lblFullName.Text = ""; MembershipUser user = Helpers.LoggedUser; if (user == null || (user != null && Roles.IsUserInRole(user.UserName, "Customer"))) { if (user != null && Roles.IsUserInRole(user.UserName, "Customer")) { hccUserProfile parentProfile = hccUserProfile.GetParentProfileBy((Guid)user.ProviderUserKey); lblFullName.Text = parentProfile.FullName; lblUserName.Text = parentProfile.FirstName; lblUserEmail.Text = user.Email; } } }
void gvwIssuedCerts_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { try { if (!string.IsNullOrWhiteSpace(e.Row.Cells[2].Text)) { Guid uid = Guid.Parse(e.Row.Cells[2].Text); hccUserProfile user = hccUserProfile.GetParentProfileBy(uid); if (user != null) { e.Row.Cells[2].Text = user.FullName; } } } catch (Exception) { } } else if (e.Row.RowType == DataControlRowType.Footer) { e.Row.Cells[0].Style.Add("text-align", "right"); e.Row.Cells[0].Text = "Total:"; e.Row.Cells[1].Text = IssuedTotal.ToString("c"); } }
protected void ButtonRefresh_Click(object sender, EventArgs e) { hccProductionCalendar cal = hccProductionCalendar.GetBy(DateTime.Parse(txtStartDate.Text)); if (cal != null) { cM.CurrentCalendarId = cal.CalendarID; } cM.CurrentCartItem = hccCartItem.GetById(int.Parse(ddlCustomers.SelectedItem.Value)); if (cM.CurrentCartItem.Plan_PlanID != null) { hccProgramPlan plan = hccProgramPlan.GetById(cM.CurrentCartItem.Plan_PlanID.Value); hccProgram program = hccProgram.GetById(plan.ProgramID); if (plan != null && program != null) { // load user profile data hccUserProfile profile = cM.CurrentCartItem.UserProfile; hccUserProfile parent = hccUserProfile.GetParentProfileBy(profile.MembershipID); lblOrderData.Text = string.Format("Order #{0}: {1}/{2}", cM.CurrentCartItem.OrderNumber, program.Name, plan.Name); lblCustData.Text = string.Format("For: {0}, {1} ({2}) Delivery Date: {3}", parent.LastName, parent.FirstName, profile.ProfileName, txtStartDate.Text); //cM.CurrentCartItem.DeliveryDate.ToShortDateString() defaultMenuSelections = hccProgramDefaultMenu.GetBy(cM.CurrentCalendarId, program.ProgramID); days = cM.BindWeeklyGlance(defaultMenuSelections, plan.NumDaysPerWeek, int.Parse(ddlCustomers.SelectedValue)); lvCustomerMealReport.DataSource = days; lvCustomerMealReport.DataBind(); } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { WebpageBase webpageBase = this.Page as WebpageBase; if (null != webpageBase) { _webpage = webpageBase.WebpageInfo; } if (_webpage != null) { Page.Title = webpageBase.Title; } //TemplateSetting example... //Header.Visible = !String.IsNullOrEmpty(HeaderImagePath); lblFullName.Text = ""; lblUserName.Text = ""; lblUserEmail.Text = ""; MembershipUser user = Helpers.LoggedUser; if (user == null || (user != null && Roles.IsUserInRole(user.UserName, "Customer"))) { if (user != null && Roles.IsUserInRole(user.UserName, "Customer")) { hccUserProfile parentProfile = hccUserProfile.GetParentProfileBy((Guid)user.ProviderUserKey); lblFullName.Text = parentProfile.FullName; lblUserName.Text = parentProfile.FirstName; lblUserEmail.Text = user.Email; } } } }
protected void Page_Load(object sender, EventArgs e) { CurrentLoggedUserID.Value = Membership.GetUser().ProviderUserKey.ToString(); string UserID = string.Empty; if (Request.QueryString.AllKeys.Contains("UserID")) { UserID = Request.QueryString["UserID"].ToString(); } if (!string.IsNullOrEmpty(UserID) && UserProfileEdit1.PrimaryKeyIndex == 0) { CurrentUserID.Value = UserID; divSearchPanel.Visible = false; btnAddNewUser.Visible = false; gvwAccounts.Visible = false; pnlGrids.Visible = false; divEdit.Visible = true; Guid aspNetId = Guid.Parse(UserID); hccUserProfile prof = hccUserProfile.GetParentProfileBy(aspNetId); if (prof != null) { UserProfileEdit1.PrimaryKeyIndex = prof.UserProfileID; } UserProfileEdit1.CurrentAspNetId = aspNetId; UserProfileEdit1.Bind(); UserProfileEdit1.Visible = true; } else if (!IsPostBack) { //BindddlDeliveryDates(); //BindgvwAccounts(); } MembershipUser user = HealthyChef.Common.Helpers.LoggedUser; IsAdmin = Roles.IsUserInRole(user.UserName, "Administrators"); IsEmployeeManager = Roles.IsUserInRole(user.UserName, "EmployeeManager"); IsEmployeeProduction = Roles.IsUserInRole(user.UserName, "EmployeeProduction"); IsEmployeeService = Roles.IsUserInRole(user.UserName, "EmployeeService"); divany.Visible = IsAdmin; divAdministrator.Visible = IsAdmin; divCustomer.Visible = IsEmployeeManager || IsAdmin || IsEmployeeService; divEmployeeManager.Visible = IsAdmin; divEmployeeProduction.Visible = IsEmployeeManager || IsAdmin; divEmployeeService.Visible = IsEmployeeManager || IsAdmin; }
protected void cstProfileName_ServerValidate(object source, ServerValidateEventArgs args) { // sub-profiles slightly different than cstProfileName_ServerValidate for main profile if (CurrentParentAspNetId.HasValue) { hccUserProfile prof = hccUserProfile.GetBy(CurrentParentAspNetId.Value, txtSubProfileName.Text.Trim()); if (prof != null && prof.UserProfileID != this.PrimaryKeyIndex) { args.IsValid = false; } } }
void AddressEdit_Billing_ControlSaved(object sender, Common.Events.ControlSavedEventArgs e) { try { hccUserProfile userProfile = hccUserProfile.GetById(this.PrimaryKeyIndex); userProfile.BillingAddressID = int.Parse(e.PrimaryKeyIndex.ToString()); userProfile.Save(); chkUpdateCard.Enabled = true; } catch (Exception ex) { throw; } }
public RoledUser(hccUserProfile profile) { StringBuilder roles = new StringBuilder(); Roles.GetRolesForUser(profile.ASPUser.UserName).ToList().ForEach(a => roles.Append(a)); //ParentUser = profile.ASPUser; ProviderUserKey = profile.ASPUser.ProviderUserKey; Email = profile.ASPUser.Email; IsApproved = profile.ASPUser.IsApproved; IsLockedOut = profile.ASPUser.IsLockedOut; IsOnline = profile.ASPUser.IsOnline; UserRoles = roles.ToString(); }
protected override void SaveForm() { hccUserProfile userProfile = hccUserProfile.GetById(this.PrimaryKeyIndex); if (userProfile != null) { // Save Address AddressEdit_Billing1.Save(); if (chkUpdateCard.Checked) { CreditCardEdit1.Save(); } } }
void SaveLedger(hccLedger ledger, hccCart CurrentCart, hccUserProfile profile) { ledger = new hccLedger { PaymentDue = CurrentCart.PaymentDue, TotalAmount = CurrentCart.TotalAmount, AspNetUserID = CurrentCart.AspNetUserID.Value, AsscCartID = CurrentCart.CartID, CreatedBy = (Guid)Helpers.LoggedUser.ProviderUserKey, CreatedDate = DateTime.Now, Description = "Cart Order Payment - Purchase Number: " + CurrentCart.PurchaseNumber.ToString() + " - from re-snapshot of order.", TransactionTypeID = (int)Enums.LedgerTransactionType.Purchase }; if (CurrentCart.IsTestOrder) { ledger.Description += " - Test Mode"; } if (CurrentCart.CreditAppliedToBalance > 0) { profile.AccountBalance = profile.AccountBalance - CurrentCart.CreditAppliedToBalance; ledger.CreditFromBalance = CurrentCart.CreditAppliedToBalance; } hccLedger lastLedger = hccLedger.GetByMembershipID(profile.MembershipID, null).OrderByDescending(a => a.CreatedDate).FirstOrDefault(); bool isDuplicateLedger = false; if (lastLedger != null) { if (ledger.CreatedBy == lastLedger.CreatedBy && ledger.CreditFromBalance == lastLedger.CreditFromBalance && ledger.Description == lastLedger.Description && ledger.PaymentDue == lastLedger.PaymentDue && ledger.TransactionTypeID == lastLedger.TransactionTypeID && ledger.TotalAmount == lastLedger.TotalAmount) { isDuplicateLedger = true; } } if (!isDuplicateLedger) { ledger.PostBalance = profile.AccountBalance; ledger.Save(); profile.Save(); } }
protected void UserProfileInfo_ControlSaved(object sender, EventArgs e) { if (CurrentUserProfile == null) { CurrentUserProfile = hccUserProfile.GetById(this.PrimaryKeyIndex); } if (CurrentUserProfile != null) { CurrentUserProfile.ShippingAddressID = AddressEdit_Shipping1.PrimaryKeyIndex; CurrentUserProfile.Save(); } // some profile value changed, make sure order numbers for current cart are still inline with one another SessionManager.CurrentUserProfileInfoChanged = true; }
protected override void LoadForm() { hccUserProfile userProfile = hccUserProfile.GetById(this.PrimaryKeyIndex); //load address CreditCardEdit1.CurrentUserProfileID = this.PrimaryKeyIndex; if (userProfile != null && userProfile.BillingAddressID.HasValue && userProfile.BillingAddressID.Value > 0) { AddressEdit_Billing1.PrimaryKeyIndex = userProfile.BillingAddressID.Value; AddressEdit_Billing1.Bind(); chkUpdateCard.Enabled = true; } // load CardInfo CreditCardEdit1.CurrentUserProfileID = this.PrimaryKeyIndex; CreditCardEdit1.Bind(); }
void rblItemType_SelectedIndexChanged(object sender, EventArgs e) { MenuItemAddToCart1.Clear(); ProgramPlanAddToCart1.Clear(); GiftCertEdit1.Clear(); if (this.PrimaryKeyIndex > 0 && CurrentCart == null) { hccUserProfile profile = hccUserProfile.GetById(this.PrimaryKeyIndex); CurrentCart = hccCart.GetCurrentCart(profile.ASPUser); } if (CurrentCart != null) { switch (rblItemType.SelectedValue) { case "1": pnlAlaCarte.Visible = true; pnlProgramPlan.Visible = false; pnlGiftCard.Visible = false; MenuItemAddToCart1.PrimaryKeyIndex = CurrentCart.CartID; MenuItemAddToCart1.Bind(); break; case "2": pnlAlaCarte.Visible = false; pnlProgramPlan.Visible = true; pnlGiftCard.Visible = false; ProgramPlanAddToCart1.PrimaryKeyIndex = CurrentCart.CartID; ProgramPlanAddToCart1.Bind(); break; case "3": pnlAlaCarte.Visible = false; pnlProgramPlan.Visible = false; pnlGiftCard.Visible = true; GiftCertEdit1.PrimaryKeyIndex = CurrentCart.CartID; GiftCertEdit1.Bind(); break; default: break; } } }
protected void gvwAccounts_SelectedIndexChanged(object sender, EventArgs e) { divSearchPanel.Visible = false; btnAddNewUser.Visible = false; gvwAccounts.Visible = false; divEdit.Visible = true; Guid aspNetId = Guid.Parse(gvwAccounts.SelectedDataKey.Value.ToString()); hccUserProfile prof = hccUserProfile.GetParentProfileBy(aspNetId); if (prof != null) { UserProfileEdit1.PrimaryKeyIndex = prof.UserProfileID; } UserProfileEdit1.CurrentAspNetId = aspNetId; UserProfileEdit1.Bind(); UserProfileEdit1.Visible = true; }
protected override void SaveForm() { if (CurrentUserProfile == null) { CurrentUserProfile = hccUserProfile.GetById(this.PrimaryKeyIndex); } if (CurrentUserProfile != null) //hccProfile exists { CurrentUserProfile.ProfileName = txtProfileName.Text.Trim(); CurrentUserProfile.FirstName = txtFirstName.Text.Trim(); CurrentUserProfile.LastName = txtLastName.Text.Trim(); CurrentUserProfile.CanyonRanchCustomer = cbMarketingOptIn.Checked; CurrentUserProfile.Save(); lblFeedback0.Text = "Account information saved: " + DateTime.Now.ToString("MM/dd/yyyy h:mm:ss"); } MembershipUser user = Membership.GetUser(CurrentUserProfile.MembershipID); if (user != null) { if (user.Email != txtEmail.Text.Trim()) // update userprofile and aspmembership user { user.Email = txtEmail.Text.Trim(); try { Membership.UpdateUser(user); lblFeedback0.ForeColor = System.Drawing.Color.Green; lblFeedback0.Text = "Account information saved: " + DateTime.Now.ToString("MM/dd/yyyy h:mm:ss"); } catch (ProviderException pex) { lblFeedback0.ForeColor = System.Drawing.Color.Red; lblFeedback0.Text = pex.Message; } catch { throw; } } } }
protected override void LoadForm() { try { if (this.PrimaryKeyIndex > 0 && CurrentCart == null) { hccUserProfile profile = hccUserProfile.GetById(this.PrimaryKeyIndex); CurrentCart = hccCart.GetCurrentCart(profile.ASPUser); } if (CurrentCart != null) { CartDisplay1.CurrentCartId = CurrentCart.CartID; CartDisplay1.Bind(); } } catch (Exception) { throw; } }
void BindgvwSubProfiles() { try { List <hccUserProfile> subProfiles = new List <hccUserProfile>(); CurrentUserProfile = hccUserProfile.GetParentProfileBy((Guid)Helpers.LoggedUser.ProviderUserKey); if (CurrentUserProfile != null) { subProfiles = CurrentUserProfile.GetSubProfiles(); } gvwSubProfiles.DataSource = subProfiles; gvwSubProfiles.DataBind(); } catch { throw; } }
private void LoadModule() { AuthNetConfig authNetConfig = new AuthNetConfig(); ltlAuthNetName.Text = authNetConfig.Settings.Name; ltlAuthNetApiKey.Text = authNetConfig.Settings.ApiKey; ltlAuthNetTransactionKey.Text = authNetConfig.Settings.TransactionKey; ltlAuthNetMode.Text = authNetConfig.Settings.TestMode ? "Test Mode" : "Live Mode"; try { CustomerInformationManager cim = new CustomerInformationManager(); hccUserProfile profile = hccUserProfile.GetRootProfiles().First(a => a.AuthNetProfileID != null); validateCustomerPaymentProfileResponse valProfile = cim.ValidateProfile(profile.AuthNetProfileID, profile.ActivePaymentProfile.AuthNetPaymentProfileID, AuthorizeNet.ValidationMode.TestMode); if (valProfile.messages.resultCode == messageTypeEnum.Ok) { lblTest.Text = "Test Validation Successful."; } else { lblTest.Text = "Test Validation Failed."; } } catch (Exception ex) { lblTest.Text = "Test Connection Failed." + ex.Message + ex.StackTrace; } //List<TestCard> cards = new List<TestCard>(); //foreach(TestCard card in credentials.TestCards) //{ // cards.Add(card); //} //TestCards.DataSource = cards; //TestCards.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { WebpageBase webpageBase = this.Page as WebpageBase; if (null != webpageBase) { _webpage = webpageBase.WebpageInfo; } if (_webpage != null) { Page.Title = webpageBase.Title; } Response.ClearHeaders(); Response.AppendHeader("Cache-Control", "no-cache"); //HTTP 1.1 Response.AppendHeader("Cache-Control", "private"); // HTTP 1.1 Response.AppendHeader("Cache-Control", "no-store"); // HTTP 1.1 Response.AppendHeader("Cache-Control", "must-revalidate"); // HTTP 1.1 Response.AppendHeader("Cache-Control", "max-stale=0"); // HTTP 1.1 Response.AppendHeader("Cache-Control", "post-check=0"); // HTTP 1.1 Response.AppendHeader("Cache-Control", "pre-check=0"); // HTTP 1.1 Response.AppendHeader("Pragma", "no-cache"); // HTTP 1.0 Response.AppendHeader("Expires", "Mon, 26 Jul 1997 05:00:00 GMT"); // HTTP 1.0 //intercom lblUserName.Text = ""; lblUserEmail.Text = ""; lblFullName.Text = ""; MembershipUser user = Helpers.LoggedUser; if (user == null || (user != null && Roles.IsUserInRole(user.UserName, "Customer"))) { if (user != null && Roles.IsUserInRole(user.UserName, "Customer")) { hccUserProfile parentProfile = hccUserProfile.GetParentProfileBy((Guid)user.ProviderUserKey); lblFullName.Text = parentProfile.FullName; lblUserName.Text = parentProfile.FirstName; lblUserEmail.Text = user.Email; } } }
void gvwSubProfiles_RowDeleting(object sender, GridViewDeleteEventArgs e) { try { int subProfileId = int.Parse(gvwSubProfiles.DataKeys[e.RowIndex].Value.ToString()); hccUserProfile delSub = hccUserProfile.GetById(subProfileId); if (delSub != null) { delSub.Activation(!delSub.IsActive); } SubProfileEdit1.Clear(); BindgvwSubProfiles(); } catch (Exception ex) { throw ex; } }
void gvwRedeemedCerts_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { try { if (!string.IsNullOrWhiteSpace(e.Row.Cells[2].Text.Trim())) { Guid iid = Guid.Parse(e.Row.Cells[2].Text); hccUserProfile iuser = hccUserProfile.GetParentProfileBy(iid); if (iuser != null) { e.Row.Cells[2].Text = iuser.FullName; } } } catch (Exception) { } try { if (!string.IsNullOrWhiteSpace(e.Row.Cells[4].Text.Trim())) { Guid rid = Guid.Parse(e.Row.Cells[4].Text); hccUserProfile ruser = hccUserProfile.GetParentProfileBy(rid); if (ruser != null) { e.Row.Cells[4].Text = ruser.FullName; } } } catch (Exception) { } } }
protected override void LoadForm() { if (CurrentUserProfile == null) { CurrentUserProfile = hccUserProfile.GetById(this.PrimaryKeyIndex); } MembershipUser user = Membership.GetUser(CurrentUserProfile.MembershipID); if (user != null) { if ((Roles.IsUserInRole(user.UserName, "Customer")) && (CurrentUserProfile != null)) { lblAccountBalance.Text = CurrentUserProfile.AccountBalance.ToString("c"); txtFirstName.Text = CurrentUserProfile.FirstName; txtLastName.Text = CurrentUserProfile.LastName; txtProfileName.Text = CurrentUserProfile.ProfileName; cbMarketingOptIn.Checked = CurrentUserProfile.CanyonRanchCustomer ?? false; txtEmail.Text = user.Email; } } }
public RoledUser(MembershipUser user) { StringBuilder roles = new StringBuilder(); Roles.GetRolesForUser(user.UserName).ToList().ForEach(a => roles.Append(a)); ProviderUserKey = user.ProviderUserKey; Email = user.Email; IsApproved = user.IsApproved; IsLockedOut = user.IsLockedOut; IsOnline = user.IsOnline; UserRoles = roles.ToString(); if (UserRoles.Contains("Customer")) { hccUserProfile profile = hccUserProfile.GetParentProfileBy((Guid)user.ProviderUserKey); //Create basic profile is user does not have one. if (profile == null) { profile = new hccUserProfile { MembershipID = (Guid)user.ProviderUserKey, CreatedBy = (Guid)Helpers.LoggedUser.ProviderUserKey, CreatedDate = DateTime.Now, IsActive = true, AccountBalance = 0.00m, ProfileName = "Main" }; profile.Save(); } else { this.FullName = profile.FullName; } } }
private void ProcessNewOrder(int cartId) { //bool dupTransaction = false; hccCart CurrentCart = null; try { // TODO: Check the cart for more then one recurring item CurrentCart = hccCart.GetById(cartId); hccUserProfile profile = hccUserProfile.GetParentProfileBy(CurrentCart.AspNetUserID.Value); hccAddress billAddr = null; var ppName = hccUserProfile.GetParentProfileBy((Guid)hccCart.GetById(cartId).AspNetUserID).ParentProfileName; var pName = hccUserProfile.GetParentProfileBy((Guid)hccCart.GetById(cartId).AspNetUserID).ASPUser.Email; //if (CurrentCart.StatusID == (int)Enums.CartStatus.Unfinalized) if (CurrentCart.StatusID == (int)Enums.CartStatus.Unfinalized) { if (profile != null) { AuthNetConfig ANConfig = new AuthNetConfig(); hccUserProfilePaymentProfile activePaymentProfile = profile.ActivePaymentProfile; bool isDuplicateTransaction = false; bool isAuthNet = false; if (ANConfig.Settings.TestMode) { CurrentCart.IsTestOrder = true; } // Check for existing account balance, calculate total balance if (CurrentCart.PaymentDue > 0.00m) { try { // if total balance remains CustomerInformationManager cim = new CustomerInformationManager(); if (activePaymentProfile != null) { // do not validate, per Duncan, YouTrack HC1-339 //string valProfile = cim.ValidateProfile(profile.AuthNetProfileID, // activePaymentProfile.AuthNetPaymentProfileID, AuthorizeNet.ValidationMode.TestMode); AuthorizeNet.Order order = new AuthorizeNet.Order(profile.AuthNetProfileID, activePaymentProfile.AuthNetPaymentProfileID, null); // charge CIM account with PaymentDue balance order.Amount = CurrentCart.PaymentDue; order.InvoiceNumber = CurrentCart.PurchaseNumber.ToString(); order.Description = "Healthy Chef Creations Purchase #" + CurrentCart.PurchaseNumber.ToString(); // Add a PO number to make purchases unique as subsequent transactions with the same amount are rejected by Auth.net as duplicate // order.PONumber = "PO" + CurrentCart.PurchaseNumber.ToString(); AuthorizeNet.IGatewayResponse rsp = cim.AuthorizeAndCapture(order); try { CurrentCart.AuthNetResponse = rsp.ResponseCode + "|" + rsp.Approved.ToString() + "|" + rsp.AuthorizationCode + "|" + rsp.InvoiceNumber + "|" + rsp.Message + "|" + rsp.TransactionID + "|" + rsp.Amount.ToString() + "|" + rsp.CardNumber; } catch (Exception) { } if (rsp.ResponseCode.StartsWith("1")) { CurrentCart.ModifiedBy = (Guid)Helpers.LoggedUser.ProviderUserKey; CurrentCart.ModifiedDate = DateTime.Now; CurrentCart.PurchaseBy = (Guid)Helpers.LoggedUser.ProviderUserKey; CurrentCart.PurchaseDate = DateTime.Now; CurrentCart.PaymentProfileID = activePaymentProfile.PaymentProfileID; CurrentCart.StatusID = (int)Enums.CartStatus.Paid; isAuthNet = true; } else if (rsp.Message.Contains("E00027")) // Duplicate transaction { order = new AuthorizeNet.Order(profile.AuthNetProfileID, activePaymentProfile.AuthNetPaymentProfileID, null) { Amount = CurrentCart.PaymentDue - .01m, // Subtract a penny from payment to make the value distinct InvoiceNumber = CurrentCart.PurchaseNumber.ToString(), Description = "Healthy Chef Creations Purchase #" + CurrentCart.PurchaseNumber.ToString() }; // charge CIM account with PaymentDue balance rsp = cim.AuthorizeAndCapture(order); try { CurrentCart.AuthNetResponse = rsp.ResponseCode + "|" + rsp.Approved.ToString() + "|" + rsp.AuthorizationCode + "|" + rsp.InvoiceNumber + "|" + rsp.Message + "|" + rsp.TransactionID + "|" + rsp.Amount.ToString() + "|" + rsp.CardNumber; if (rsp.ResponseCode.StartsWith("1")) { //CurrentCart.PaymentDue = CurrentCart.PaymentDue - .01m; CurrentCart.ModifiedBy = (Guid)Helpers.LoggedUser.ProviderUserKey; CurrentCart.ModifiedDate = DateTime.Now; CurrentCart.PurchaseBy = (Guid)Helpers.LoggedUser.ProviderUserKey; CurrentCart.PurchaseDate = DateTime.Now; CurrentCart.PaymentProfileID = activePaymentProfile.PaymentProfileID; CurrentCart.StatusID = (int)Enums.CartStatus.Paid; isAuthNet = true; } else { lblConfirmFeedback.Text += "Authorize.Net " + rsp.Message + @" (" + ppName + @", " + pName + @")" + @"<br />"; // CurrentCart.AuthNetResponse; lblConfirmFeedback.ForeColor = System.Drawing.Color.Red; } } catch (Exception) { } } else { lblConfirmFeedback.Text += "Authorize.Net " + rsp.Message + @" (" + ppName + @", " + pName + @")" + @"<br />"; // CurrentCart.AuthNetResponse; lblConfirmFeedback.ForeColor = System.Drawing.Color.Red; } CurrentCart.Save(); } else { lblConfirmFeedback.Text += "No payment profile found." + @" (" + ppName + @", " + pName + @")" + @"<br />"; } } catch (Exception ex) { lblConfirmFeedback.Text += "Authorize.Net " + ex.Message + @" (" + ppName + @", " + pName + @")" + @"<br />"; lblConfirmFeedback.ForeColor = System.Drawing.Color.Red; if (ex is InvalidOperationException) { if (CurrentCart.IsTestOrder) { CurrentCart.ModifiedBy = (Guid)Helpers.LoggedUser.ProviderUserKey; CurrentCart.ModifiedDate = DateTime.Now; CurrentCart.PaymentProfileID = activePaymentProfile.PaymentProfileID; CurrentCart.AuthNetResponse = ex.Message; CurrentCart.StatusID = (int)Enums.CartStatus.Unfinalized; CurrentCart.Save(); } else { BayshoreSolutions.WebModules.WebModulesAuditEvent.Raise(ex.Message, this, ex); lblConfirmFeedback.Visible = true; lblConfirmFeedback.Text += "Authorize.Net " + ex.Message + @" (" + ppName + @", " + pName + @")" + @"<br />"; lblConfirmFeedback.ForeColor = System.Drawing.Color.Red; } } else { throw; } } } else { // no balance left to pay on order, set as paid CurrentCart.AuthNetResponse = "Paid with account balance."; CurrentCart.ModifiedBy = (Guid)Helpers.LoggedUser.ProviderUserKey; CurrentCart.ModifiedDate = DateTime.Now; CurrentCart.PurchaseBy = (Guid)Helpers.LoggedUser.ProviderUserKey; CurrentCart.PurchaseDate = DateTime.Now; CurrentCart.StatusID = (int)Enums.CartStatus.Paid; CurrentCart.Save(); } if ((Enums.CartStatus)CurrentCart.StatusID == Enums.CartStatus.Paid) //&& !isDuplicateTransaction { hccLedger ledger = new hccLedger { //PaymentDue = dupTransaction ? CurrentCart.PaymentDue : CurrentCart.PaymentDue - .01m, //TotalAmount = dupTransaction ? CurrentCart.TotalAmount : CurrentCart.TotalAmount - .01m, PaymentDue = CurrentCart.PaymentDue, TotalAmount = CurrentCart.TotalAmount, AspNetUserID = CurrentCart.AspNetUserID.Value, AsscCartID = CurrentCart.CartID, CreatedBy = (Guid)Helpers.LoggedUser.ProviderUserKey, CreatedDate = DateTime.Now, Description = "Cart Order Payment - Purchase Number: " + CurrentCart.PurchaseNumber.ToString(), TransactionTypeID = (int)Enums.LedgerTransactionType.Purchase }; if (CurrentCart.IsTestOrder) { ledger.Description += " - Test Mode"; } if (CurrentCart.CreditAppliedToBalance > 0) { profile.AccountBalance = profile.AccountBalance - CurrentCart.CreditAppliedToBalance; ledger.CreditFromBalance = CurrentCart.CreditAppliedToBalance; } hccLedger lastLedger = hccLedger.GetByMembershipID(profile.MembershipID, null) .OrderByDescending(a => a.CreatedDate) .FirstOrDefault(); bool isDuplicateLedger = false; if (lastLedger != null) { if (ledger.CreatedBy == lastLedger.CreatedBy && ledger.CreditFromBalance == lastLedger.CreditFromBalance && ledger.Description == lastLedger.Description && ledger.PaymentDue == lastLedger.PaymentDue && ledger.TransactionTypeID == lastLedger.TransactionTypeID && ledger.TotalAmount == lastLedger.TotalAmount) { isDuplicateLedger = true; } } if (!isDuplicateLedger) { ledger.PostBalance = profile.AccountBalance; ledger.Save(); profile.Save(); // create snapshot here hccCartSnapshot snap = new hccCartSnapshot { CartId = cartId, MembershipId = profile.MembershipID, LedgerId = ledger.LedgerID, AccountBalance = profile.AccountBalance, AuthNetProfileId = profile.AuthNetProfileID, CreatedBy = (Guid)Helpers.LoggedUser.ProviderUserKey, CreatedDate = DateTime.Now, DefaultCouponId = profile.DefaultCouponId, Email = profile.ASPUser.Email, FirstName = profile.FirstName, LastName = profile.LastName, ProfileName = profile.ProfileName, AuthNetPaymentProfileId = (isAuthNet == true ? activePaymentProfile.AuthNetPaymentProfileID : string.Empty), CardTypeId = (isAuthNet == true ? activePaymentProfile.CardTypeID : 0), CCLast4 = (isAuthNet == true ? activePaymentProfile.CCLast4 : string.Empty), ExpMon = (isAuthNet == true ? activePaymentProfile.ExpMon : 0), ExpYear = (isAuthNet == true ? activePaymentProfile.ExpYear : 0), NameOnCard = (isAuthNet == true ? activePaymentProfile.NameOnCard : string.Empty) }; snap.Save(); hccUserProfile parentProfile = hccUserProfile.GetParentProfileBy(CurrentCart.AspNetUserID.Value); if (parentProfile.BillingAddressID.HasValue) { billAddr = hccAddress.GetById(parentProfile.BillingAddressID.Value); } hccAddress snapBillAddr = new hccAddress { Address1 = billAddr.Address1, Address2 = billAddr.Address2, AddressTypeID = (int)Enums.AddressType.BillingSnap, City = billAddr.City, Country = billAddr.Country, DefaultShippingTypeID = billAddr.DefaultShippingTypeID, FirstName = billAddr.FirstName, IsBusiness = billAddr.IsBusiness, LastName = billAddr.LastName, Phone = billAddr.Phone, PostalCode = billAddr.PostalCode, State = billAddr.State, ProfileName = parentProfile.ProfileName }; snapBillAddr.Save(); // copy and replace of all addresses for snapshot List <hccCartItem> cartItems = hccCartItem.GetBy(CurrentCart.CartID); cartItems.ToList().ForEach(delegate(hccCartItem ci) { hccAddress shipAddr = null; if (ci.UserProfile.ShippingAddressID.HasValue) { shipAddr = hccAddress.GetById(ci.UserProfile.ShippingAddressID.Value); } if (shipAddr != null) { hccAddress snapShipAddr = new hccAddress { Address1 = shipAddr.Address1, Address2 = shipAddr.Address2, AddressTypeID = (int)Enums.AddressType.ShippingSnap, City = shipAddr.City, Country = shipAddr.Country, DefaultShippingTypeID = shipAddr.DefaultShippingTypeID, FirstName = shipAddr.FirstName, IsBusiness = shipAddr.IsBusiness, LastName = shipAddr.LastName, Phone = shipAddr.Phone, PostalCode = shipAddr.PostalCode, State = shipAddr.State, ProfileName = ci.UserProfile.ProfileName }; snapShipAddr.Save(); ci.SnapShipAddrId = snapShipAddr.AddressID; } ci.SnapBillAddrId = snapBillAddr.AddressID; ci.Save(); }); try { Email.EmailController ec = new Email.EmailController(); ec.SendMail_OrderConfirmationMerchant(profile.FirstName + " " + profile.LastName, CurrentCart.ToHtml(), cartId); ec.SendMail_OrderConfirmationCustomer(profile.ASPUser.Email, profile.FirstName + " " + profile.LastName, CurrentCart.ToHtml()); } catch (Exception ex) { BayshoreSolutions.WebModules.WebModulesAuditEvent.Raise("Send Mail Failed", this, ex); } //throw; } //if (IsForPublic) //{ // Response.Redirect(string.Format("~/cart/order-confirmation.aspx?pn={0}&tl={1}&tx={2}&ts={3}&ct={4}&st={5}&cy={6}", // CurrentCart.PurchaseNumber, CurrentCart.TotalAmount, CurrentCart.TaxableAmount, CurrentCart.ShippingAmount, // billAddr.City, billAddr.State, billAddr.Country), false); //} //else //{ // CurrentCart = hccCart.GetCurrentCart(profile.ASPUser); // CurrentCartId = CurrentCart.CartID; // pnlCartDisplay.Visible = true; // pnlConfirm.Visible = false; // Clear(); // Bind(); //} //OnCartSaved(new CartEventArgs(CurrentCartId)); } } //else //{ // BayshoreSolutions.WebModules.WebModulesAuditEvent.Raise("Duplicate transaction attempted: " + CurrentCart.PurchaseNumber.ToString(), this, new Exception("Duplicate transaction attempted by:" + Helpers.LoggedUser.UserName)); //} } else { Response.Redirect("~/login.aspx", true); } } //else //{ //if (IsForPublic) //{ // //Response.Redirect("~/cart/order-confirmation.aspx?cid=" + CurrentCartId.ToString(), false); // Response.Redirect(string.Format("~/cart/order-confirmation.aspx?pn={0}&tl={1}&tx={2}&ts={3}&ct={4}&st={5}&cy={6}", // CurrentCart.PurchaseNumber, CurrentCart.TotalAmount, CurrentCart.TaxableAmount, CurrentCart.ShippingAmount, // billAddr.City, billAddr.State, billAddr.Country), false); //} //else //{ // CurrentCart = hccCart.GetCurrentCart(profile.ASPUser); // CurrentCartId = CurrentCart.CartID; // pnlCartDisplay.Visible = true; // pnlConfirm.Visible = false; // Clear(); // Bind(); // OnCartSaved(new CartEventArgs(CurrentCartId)); //} //} } catch (Exception ex) { BayshoreSolutions.WebModules.WebModulesAuditEvent.Raise(ex.Data + " " + ex.InnerException, this, new Exception("Recurring order error in method ProcessNewOrder: " + Helpers.LoggedUser.UserName)); } }
public string UpdateCarts(List <UpdateCartItem> carts) { try { UpdateCartItem updatecart = carts[0]; hccCart CurrentCart = hccCart.GetById(updatecart.cartId); hccUserProfile ownerProfile = CurrentCart.OwnerProfile; hccAddress snapBillAddr = null; List <hccCartItem> cartItems = null; bool isAuthNet = false; hccLedger ledger = null; string retVal = string.Empty; if (CurrentCart != null && ownerProfile != null) { hccAddress billAddr = null; hccUserProfilePaymentProfile activePaymentProfile = ownerProfile.ActivePaymentProfile; if (updatecart.updateStatus && CurrentCart.StatusID != updatecart.statusId) { CurrentCart.StatusID = updatecart.statusId; CurrentCart.ModifiedBy = (Guid)Helpers.LoggedUser.ProviderUserKey; CurrentCart.ModifiedDate = DateTime.Now; if (updatecart.statusId == (int)Enums.CartStatus.Paid) { if (!CurrentCart.PurchaseBy.HasValue) { CurrentCart.PurchaseBy = (Guid)Helpers.LoggedUser.ProviderUserKey; } if (!CurrentCart.PurchaseDate.HasValue) { CurrentCart.PurchaseDate = DateTime.Now; } } CurrentCart.Save(); } if (updatecart.updateAddresses) // re-snap addresses { if (ownerProfile.BillingAddressID.HasValue) { billAddr = hccAddress.GetById(ownerProfile.BillingAddressID.Value); if (billAddr != null) { snapBillAddr = new hccAddress { Address1 = billAddr.Address1, Address2 = billAddr.Address2, AddressTypeID = (int)Enums.AddressType.BillingSnap, City = billAddr.City, Country = billAddr.Country, DefaultShippingTypeID = billAddr.DefaultShippingTypeID, FirstName = billAddr.FirstName, IsBusiness = billAddr.IsBusiness, LastName = billAddr.LastName, Phone = billAddr.Phone, PostalCode = billAddr.PostalCode, State = billAddr.State, ProfileName = ownerProfile.ProfileName }; snapBillAddr.Save(); } } else { retVal += "Profile has no billing address on record."; } if (cartItems == null) { cartItems = hccCartItem.GetBy(CurrentCart.CartID); } cartItems.ForEach(delegate(hccCartItem ci) { hccAddress shipAddr = null; if (snapBillAddr != null) { ci.SnapBillAddrId = snapBillAddr.AddressID; } if (ci.UserProfile == null) { ci.UserProfileID = ownerProfile.UserProfileID; } if (ci.UserProfile.ShippingAddressID.HasValue) { shipAddr = hccAddress.GetById(ci.UserProfile.ShippingAddressID.Value); } if (shipAddr != null) { hccAddress snapShipAddr = new hccAddress { Address1 = shipAddr.Address1, Address2 = shipAddr.Address2, AddressTypeID = (int)Enums.AddressType.ShippingSnap, City = shipAddr.City, Country = shipAddr.Country, DefaultShippingTypeID = shipAddr.DefaultShippingTypeID, FirstName = shipAddr.FirstName, IsBusiness = shipAddr.IsBusiness, LastName = shipAddr.LastName, Phone = shipAddr.Phone, PostalCode = shipAddr.PostalCode, State = shipAddr.State, ProfileName = ci.UserProfile.ProfileName }; snapShipAddr.Save(); ci.SnapShipAddrId = snapShipAddr.AddressID; } ci.Save(); }); } if (updatecart.rerunAuthNet) { CurrentCart.StatusID = (int)Enums.CartStatus.Unfinalized; CurrentCart.PurchaseBy = null; CurrentCart.PurchaseDate = null; if (ownerProfile != null) { AuthNetConfig ANConfig = new AuthNetConfig(); if (ANConfig.Settings.TestMode) { CurrentCart.IsTestOrder = true; } if (CurrentCart.PaymentDue > 0.00m) { try { // if total balance remains CustomerInformationManager cim = new CustomerInformationManager(); if (activePaymentProfile != null) { AuthorizeNet.Order order = new AuthorizeNet.Order(ownerProfile.AuthNetProfileID, activePaymentProfile.AuthNetPaymentProfileID, null); // charge CIM account with PaymentDue balance order.Amount = CurrentCart.PaymentDue; order.InvoiceNumber = CurrentCart.PurchaseNumber.ToString(); order.Description = "Healthy Chef Creations Purchase #" + CurrentCart.PurchaseNumber.ToString(); AuthorizeNet.IGatewayResponse rsp = cim.AuthorizeAndCapture(order); try { CurrentCart.AuthNetResponse = rsp.ResponseCode + "|" + rsp.Approved.ToString() + "|" + rsp.AuthorizationCode + "|" + rsp.InvoiceNumber + "|" + rsp.Message + "|" + rsp.TransactionID + "|" + rsp.Amount.ToString() + "|" + rsp.CardNumber; } catch (Exception) { } if (rsp.ResponseCode.StartsWith("1")) { CurrentCart.ModifiedBy = (Guid)Helpers.LoggedUser.ProviderUserKey; CurrentCart.ModifiedDate = DateTime.Now; CurrentCart.PurchaseBy = (Guid)Helpers.LoggedUser.ProviderUserKey; CurrentCart.PurchaseDate = DateTime.Now; CurrentCart.PaymentProfileID = activePaymentProfile.PaymentProfileID; CurrentCart.StatusID = (int)Enums.CartStatus.Paid; isAuthNet = true; } CurrentCart.Save(); } else { return("No active payment profile."); } } catch (Exception ex) { if (ex is InvalidOperationException) { if (CurrentCart.IsTestOrder) { CurrentCart.ModifiedBy = (Guid)Helpers.LoggedUser.ProviderUserKey; CurrentCart.ModifiedDate = DateTime.Now; CurrentCart.PaymentProfileID = activePaymentProfile.PaymentProfileID; CurrentCart.AuthNetResponse = ex.Message; CurrentCart.StatusID = (int)Enums.CartStatus.Unfinalized; CurrentCart.Save(); } else { BayshoreSolutions.WebModules.WebModulesAuditEvent.Raise(ex.Message, this, ex); } } else { throw; } } } else { // no balance left to pay on order, set as paid CurrentCart.AuthNetResponse = "Paid with account balance."; CurrentCart.ModifiedBy = (Guid)Helpers.LoggedUser.ProviderUserKey; CurrentCart.ModifiedDate = DateTime.Now; CurrentCart.PurchaseBy = (Guid)Helpers.LoggedUser.ProviderUserKey; CurrentCart.PurchaseDate = DateTime.Now; CurrentCart.StatusID = (int)Enums.CartStatus.Paid; CurrentCart.Save(); } } } if (updatecart.createLedgerEntry) { if (ledger == null) { ledger = hccLedger.GetBy(CurrentCart.CartID); } if (ledger == null) { SaveLedger(ledger, CurrentCart, ownerProfile); } } if (updatecart.createNewSnapshot) { if (((Enums.CartStatus)CurrentCart.StatusID) == Enums.CartStatus.Paid) { if (ledger == null) { ledger = hccLedger.GetBy(CurrentCart.CartID); } if (ledger == null) // it still equals null { SaveLedger(ledger, CurrentCart, ownerProfile); } // create snapshot here hccCartSnapshot snap = new hccCartSnapshot { CartId = CurrentCart.CartID, MembershipId = ownerProfile.MembershipID, LedgerId = ledger.LedgerID, AccountBalance = ownerProfile.AccountBalance, AuthNetProfileId = ownerProfile.AuthNetProfileID, CreatedBy = (Guid)Helpers.LoggedUser.ProviderUserKey, CreatedDate = DateTime.Now, DefaultCouponId = ownerProfile.DefaultCouponId, Email = ownerProfile.ASPUser.Email, FirstName = ownerProfile.FirstName, LastName = ownerProfile.LastName, ProfileName = ownerProfile.ProfileName }; if (isAuthNet) { if (activePaymentProfile != null) { snap.AuthNetPaymentProfileId = activePaymentProfile.AuthNetPaymentProfileID; snap.CardTypeId = activePaymentProfile.CardTypeID; snap.CCLast4 = activePaymentProfile.CCLast4; snap.ExpMon = activePaymentProfile.ExpMon; snap.ExpYear = activePaymentProfile.ExpYear; snap.NameOnCard = activePaymentProfile.NameOnCard; } else { return("No active payment profile."); } } else { snap.AuthNetPaymentProfileId = string.Empty; snap.CardTypeId = 0; snap.CCLast4 = string.Empty; snap.ExpMon = 0; snap.ExpYear = 0; snap.NameOnCard = string.Empty; } snap.Save(); if (billAddr == null && ownerProfile.BillingAddressID.HasValue) { billAddr = hccAddress.GetById(ownerProfile.BillingAddressID.Value); } if (billAddr != null) { snapBillAddr = new hccAddress { Address1 = billAddr.Address1, Address2 = billAddr.Address2, AddressTypeID = billAddr.AddressTypeID, City = billAddr.City, Country = billAddr.Country, DefaultShippingTypeID = billAddr.DefaultShippingTypeID, FirstName = billAddr.FirstName, IsBusiness = billAddr.IsBusiness, LastName = billAddr.LastName, Phone = billAddr.Phone, PostalCode = billAddr.PostalCode, State = billAddr.State, ProfileName = ownerProfile.ProfileName }; snapBillAddr.Save(); } else { retVal += "Profile has no billing address on record."; } // copy and replace of all addresses for snapshot if (cartItems == null) { cartItems = hccCartItem.GetBy(CurrentCart.CartID); } cartItems.ToList().ForEach(delegate(hccCartItem ci) { if (snapBillAddr != null) { ci.SnapBillAddrId = snapBillAddr.AddressID; } hccAddress shipAddr = null; if (ci.UserProfile.ShippingAddressID.HasValue) { shipAddr = hccAddress.GetById(ci.UserProfile.ShippingAddressID.Value); } if (shipAddr != null) { hccAddress snapShipAddr = new hccAddress { Address1 = shipAddr.Address1, Address2 = shipAddr.Address2, AddressTypeID = shipAddr.AddressTypeID, City = shipAddr.City, Country = shipAddr.Country, DefaultShippingTypeID = shipAddr.DefaultShippingTypeID, FirstName = shipAddr.FirstName, IsBusiness = shipAddr.IsBusiness, LastName = shipAddr.LastName, Phone = shipAddr.Phone, PostalCode = shipAddr.PostalCode, State = shipAddr.State, ProfileName = ci.UserProfile.ProfileName }; snapShipAddr.Save(); ci.SnapShipAddrId = snapShipAddr.AddressID; } else { retVal += "Profile has no billing address on record."; } ci.Save(); }); } } if (updatecart.sendCustomerEmail) { try { Email.EmailController ec = new Email.EmailController(); ec.SendMail_OrderConfirmationMerchant(ownerProfile.FirstName + " " + ownerProfile.LastName, CurrentCart.ToHtml(), CurrentCart.CartID); } catch (Exception ex) { BayshoreSolutions.WebModules.WebModulesAuditEvent.Raise("Send Merchant Mail Failed", this, ex); } } if (updatecart.sendMerchantEmail) { try { Email.EmailController ec = new Email.EmailController(); ec.SendMail_OrderConfirmationCustomer(ownerProfile.ASPUser.Email, ownerProfile.FirstName + " " + ownerProfile.LastName, CurrentCart.ToHtml()); } catch (Exception ex) { BayshoreSolutions.WebModules.WebModulesAuditEvent.Raise("Send customer Mail Failed", this, ex); } } if (updatecart.repairCartCals) { if (cartItems == null) { cartItems = hccCartItem.GetBy(CurrentCart.CartID); } // wrap in programs cartItems.ForEach(delegate(hccCartItem ci) { if (ci.ItemType == Enums.CartItemType.DefinedPlan) { hccProgramPlan cp = hccProgramPlan.GetById(ci.Plan_PlanID.Value); if (cp != null) { for (int i = 0; i < cp.NumWeeks; i++) { hccProductionCalendar cal; cal = hccProductionCalendar.GetBy(ci.DeliveryDate.AddDays(7 * i)); if (cal != null) { hccCartItemCalendar existCal = hccCartItemCalendar.GetBy(ci.CartItemID, cal.CalendarID); if (existCal == null) { hccCartItemCalendar cartCal = new hccCartItemCalendar { CalendarID = cal.CalendarID, CartItemID = ci.CartItemID, IsFulfilled = false }; cartCal.Save(); } } else { BayshoreSolutions.WebModules.WebModulesAuditEvent.Raise( "No production calendar found for Delivery Date: " + ci.DeliveryDate.AddDays(7 * i).ToShortDateString(), this); } } } } }); } if (updatecart.reCalcItemTax) { try { if (cartItems == null) { cartItems = hccCartItem.GetBy(CurrentCart.CartID); } List <ProfileCart> CurrentProfileCarts = new List <ProfileCart>(); if (cartItems.Count > 0) { hccUserProfile parentProfile = hccUserProfile.GetParentProfileBy(CurrentCart.AspNetUserID.Value); //List<hccProductionCalendar> pc = new List<hccProductionCalendar>(); foreach (hccCartItem cartItem in cartItems) { ProfileCart profCart; int shippingAddressId; //if (!pc.Exists(a => a.DeliveryDate == cartItem.DeliveryDate)) // pc.Add(hccProductionCalendar.GetBy(cartItem.DeliveryDate)); //hccProductionCalendar cpc = pc.SingleOrDefault(a => a.DeliveryDate == cartItem.DeliveryDate); //if (cpc != null && (cpc.OrderCutOffDate.AddDays(1) >= DateTime.Now || (HttpContext.Current.Request.Url.OriginalString.Contains("Admin")))) //{ if (cartItem.UserProfile != null && (cartItem.UserProfile.UseParentShipping || cartItem.UserProfile.ShippingAddressID.HasValue)) { if (cartItem.UserProfile.UseParentShipping) { shippingAddressId = parentProfile.ShippingAddressID.Value; } else { shippingAddressId = cartItem.UserProfile.ShippingAddressID.Value; } profCart = CurrentProfileCarts .SingleOrDefault(a => a.ShippingAddressId == shippingAddressId && a.DeliveryDate == cartItem.DeliveryDate); } else { profCart = CurrentProfileCarts .SingleOrDefault(a => a.ShippingAddressId == 0 && a.DeliveryDate == cartItem.DeliveryDate); shippingAddressId = 0; } if (profCart == null) { profCart = new ProfileCart(shippingAddressId, cartItem.DeliveryDate); CurrentProfileCarts.Add(profCart); } profCart.CartItems.Add(cartItem); //} //else //{ // //cartItem.Delete(); // //lblFeedbackCart.Text = "Item(s) removed from cart due to expiration of availability."; //} } } //// display totals CurrentCart.CalculateTotals(CurrentProfileCarts); } catch (Exception ex) { BayshoreSolutions.WebModules.WebModulesAuditEvent.Raise("Attempt to recalculate taz for cart items failed.", this, ex); } } } return("Cart Updated: " + DateTime.Now); } catch (Exception ex) { throw ex; } }
protected void btnLogin_Click(object sender, EventArgs e) { try { if (rdoCustomerType.SelectedIndex == 0) { //Check to see that the e-mail address hasn't already been taken var users = (from MembershipUser u in Membership.GetAllUsers() where u.Email == txtEmail.Text.Trim() select new { Email = u.Email }).ToList(); if (users.Count == 0) { usrctrlRegister.Email = txtEmail.Text.Trim(); multiViews.ActiveViewIndex = (int)LoginView.Registration; Page.Title = "Account Sign Up"; } else { litMessage.Text = "The e-mail address you entered is already in use."; } } else { string userName = Membership.GetUserNameByEmail(txtEmail.Text.Trim()); if (userName == null) { userName = txtEmail.Text.Trim(); } if (Membership.ValidateUser(userName, txtPassword.Text.Trim())) { MembershipUser user = Membership.GetUser(userName); string [] roles = Roles.GetRolesForUser(userName); if (user != null) { // ensure user has Customer record in db hccCart unloggedCart = hccCart.GetCurrentCart(); hccCart loggedCart = hccCart.GetCurrentCart(user); if (unloggedCart != null) { hccUserProfile parentProfile = hccUserProfile.GetParentProfileBy((Guid)user.ProviderUserKey); if (parentProfile != null) // no profile for user OR is Admin and admin's dont have profiles { List <hccCartItem> unloggedcartItems = hccCartItem.GetBy(unloggedCart.CartID); List <hccCartItem> loggedcartItems = hccCartItem.GetBy(loggedCart.CartID); unloggedcartItems.ToList().ForEach(delegate(hccCartItem item) { hccCartItem modelItem = loggedcartItems.FirstOrDefault(a => a.UserProfileID == parentProfile.UserProfileID && a.DeliveryDate == item.DeliveryDate); if (modelItem != null) { item.OrderNumber = modelItem.OrderNumber; } else { item.GetOrderNumber(loggedCart); } item.UserProfileID = parentProfile.UserProfileID; if (item.ItemType == Enums.CartItemType.GiftCard) { if (item.Gift_IssuedTo == null || item.Gift_IssuedTo == Guid.Empty) { item.Gift_IssuedTo = parentProfile.MembershipID; item.Gift_IssuedDate = DateTime.Now; } } item.CartID = loggedCart.CartID; item.Save(); }); unloggedCart.StatusID = (int)Enums.CartStatus.Cancelled; unloggedCart.Save(); } } } if (Request.QueryString["fc"] != null) { FormsAuthentication.SetAuthCookie(userName, true); Response.Redirect("~/cart.aspx?confirm=1", true); } else { // Was user redirected from meal programs due to recurring selection if (Request.QueryString["rp"] != null) { FormsAuthentication.SetAuthCookie(userName, true); Response.Redirect("~/details/" + Request.QueryString["rp"] + "?rc=true"); } else { FormsAuthentication.RedirectFromLoginPage(userName, true); } } } else { MembershipUser user = Membership.GetUser(userName); if (user == null || !Membership.ValidateUser(userName, txtPassword.Text.Trim())) { litMessage.Text = "Login Attempt Failed. Email/password combination not recognized. Please re-enter your email address and account password. If you have forgotten your password, please click the link below or call customer service at 866-575-2433 for assistance."; } else if (!user.IsApproved) { litMessage.Text = "That account has been deactivated. Please contact customer service at 866-575-2433 for assistance."; } else if (user.IsLockedOut) { //password lock-out litMessage.Text = "That account is locked out. Please contact customer service at 866-575-2433 for assistance."; } } } } catch (Exception) { throw; } }
protected override void LoadForm() { try { hccProductionCalendar cal = null; if (Request.QueryString["dd"] != null && !string.IsNullOrEmpty(Request.QueryString["dd"])) { DateTime _delDate = DateTime.ParseExact(Request.QueryString["dd"].ToString(), "M/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture); cal = hccProductionCalendar.GetBy(_delDate); //cal = hccProductionCalendar.GetBy(DateTime.Parse(Request.QueryString["dd"].ToString())); if (cal != null) { CurrentCalendarId = cal.CalendarID; } lkbBack.PostBackUrl += "?cal=" + cal.CalendarID.ToString(); } hccProgramPlan plan = hccProgramPlan.GetById(CurrentCartItem.Plan_PlanID.Value); hccProgram program = hccProgram.GetById(plan.ProgramID); if (plan != null && program != null) { CurrentProgramId = program.ProgramID; CurrentNumOfDays = plan.NumDaysPerWeek; // load user profile data hccUserProfile profile = CurrentCartItem.UserProfile; hccUserProfile parent = hccUserProfile.GetParentProfileBy(profile.MembershipID); lblCustomerName.Text = parent.FirstName + " " + parent.LastName; lblProfileName.Text = profile.ProfileName; lblProgram.Text = program.Name; lblPlan.Text = plan.Name; lblPlanOption.Text = hccProgramOption.GetById(CurrentCartItem.Plan_ProgramOptionID.Value).OptionText; lblOrderNumber.Text = CurrentCartItem.OrderNumber; lblQuantity.Text = CurrentCartItem.Quantity.ToString(); lblDeliveryDate.Text = cal.DeliveryDate.ToShortDateString(); hccCartItemCalendar cartCal = hccCartItemCalendar.GetBy(CurrentCartItem.CartItemID, cal.CalendarID); if (cartCal != null) { chkIsComplete.Checked = cartCal.IsFulfilled; } chkIsCancelledDisplay.Checked = CurrentCartItem.IsCancelled; lvwAllrgs.DataSource = profile.GetAllergens(); lvwAllrgs.DataBind(); ProfileNotesEdit_AllergenNote.CurrentUserProfileId = profile.UserProfileID; ProfileNotesEdit_AllergenNote.Bind(); lvwPrefs.DataSource = profile.GetPreferences(); lvwPrefs.DataBind(); ProfileNotesEdit_PreferenceNote.CurrentUserProfileId = profile.UserProfileID; ProfileNotesEdit_PreferenceNote.Bind(); defaultMenuSelections = hccProgramDefaultMenu.GetBy(CurrentCalendarId, CurrentProgramId); days = BindWeeklyGlance(defaultMenuSelections, CurrentNumOfDays); BindDdlDays(days); BindForm(); } } catch (Exception) { throw; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Request.QueryString["pn"] != null && !string.IsNullOrWhiteSpace(Request.QueryString["pn"].ToString())) { int purchaseNum; if (int.TryParse(Request.QueryString["pn"], out purchaseNum)) { CurrentCart = hccCart.GetBy(purchaseNum); } } if (CurrentCart != null && Helpers.LoggedUser != null && (CurrentCart.AspNetUserID == (Guid)Helpers.LoggedUser.ProviderUserKey || Roles.IsUserInRole(Helpers.LoggedUser.UserName, "Administrators"))) { lblCompleteDetail.Text = CurrentCart.ToHtml(); if (CurrentCart.OwnerProfile != null && CurrentCart.OwnerProfile.ASPUser != null) { lblCompleteEmail.Text = CurrentCart.OwnerProfile.ASPUser.Email; } //hdnPurchaseNum.Value = this.PurchaseNumber.ToString(); //hdnTotal.Value = this.TotalAmount.ToString("f2"); //hdnTax.Value = this.TaxAmount.ToString("f2"); //hdnShipping.Value = this.ShippingAmount.ToString("f2"); hccUserProfile billProf = hccUserProfile.GetParentProfileBy(CurrentCart.AspNetUserID.Value); if (billProf != null) { hccAddress billAddr = null; if (billProf.BillingAddressID.HasValue) { billAddr = hccAddress.GetById(billProf.BillingAddressID.Value); } if (billAddr != null) { CurrentCity = billAddr.City; CurrentState = billAddr.State; CurrentCountry = billAddr.Country; //CurrentUserName = billAddr.FirstName; //CurrentUserEmail = billProf.aspnet_Membership.Email; } else { CurrentCity = string.Empty; CurrentState = string.Empty; CurrentCountry = string.Empty; //CurrentUserName = string.Empty; //CurrentUserEmail = string.Empty; } } else { CurrentCity = string.Empty; CurrentState = string.Empty; CurrentCountry = string.Empty; //CurrentUserName = string.Empty; //CurrentUserEmail = string.Empty; } //string TrackAmount = "'" + CurrentCart.TotalAmount.ToString("f2") + "'"; //Session["trackAmount"] = TrackAmount; //track_id.Attributes["src"] = ResolveUrl("https://shareasale.com/sale.cfm?amount=TrackAmount&[email protected]&transtype=lead&merchantID=11"); StringBuilder sb = new StringBuilder(); sb.AppendLine("var _gaq = _gaq || [];"); sb.AppendLine("_gaq.push(['_setAccount', 'UA-32947650-1']);"); sb.AppendLine("_gaq.push(['_trackPageview']);"); sb.AppendLine("_gaq.push(['_addTrans',"); sb.AppendLine("'" + CurrentCart.PurchaseNumber.ToString() + "', // transaction ID - required"); sb.AppendLine("'Healthy Chef Creations', // affiliation or store name"); sb.AppendLine("'" + CurrentCart.TotalAmount.ToString("f2") + "', // total - required"); sb.AppendLine("'" + CurrentCart.TaxAmount.ToString("f2") + "', // tax"); sb.AppendLine("'" + CurrentCart.ShippingAmount.ToString("f2") + "', // shipping"); sb.AppendLine("'" + CurrentCity + "', // city"); sb.AppendLine("'" + CurrentState + "', // state or province"); sb.AppendLine("'" + CurrentCountry + "' // country"); //sb.AppendLine("'" + CurrentUserName + "' User Name//"); //sb.AppendLine("'" + CurrentUserEmail + "' User Email//"); sb.AppendLine("]);"); sb.AppendLine("_gaq.push(['_trackTrans']); //submits transaction to the Analytics servers"); sb.AppendLine("(function() {"); sb.AppendLine("var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;"); sb.AppendLine("ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';"); sb.AppendLine("var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);"); sb.AppendLine("})();"); if (!ClientScript.IsStartupScriptRegistered("GoogleTrack")) { Page.ClientScript.RegisterStartupScript(this.GetType(), "GoogleTrack", sb.ToString(), true); } Response.Redirect(string.Format("~/thankyou.aspx?pn={0}&tl={1}&tx={2}&ts={3}&ct={4}&st={5}&cy={6}", CurrentCart.PurchaseNumber, CurrentCart.TotalAmount, CurrentCart.TaxableAmount, CurrentCart.ShippingAmount, hccAddress.GetById(CurrentCart.OwnerProfile.BillingAddressID.Value).City, hccAddress.GetById(CurrentCart.OwnerProfile.BillingAddressID.Value).State, hccAddress.GetById(CurrentCart.OwnerProfile.BillingAddressID.Value).Country), true); } else { pnlComplete.Visible = false; lblFeedback.Text = "You are not authorized to view this information."; } if (HttpContext.Current.User.Identity.IsAuthenticated) { aLogin.Visible = false; aProfile.Visible = true; aSignOut.Visible = true; } else { aCart.Visible = true; aLogin.Visible = true; aProfile.Visible = false; aSignOut.Visible = false; } SetCartCount(); } }