public ActionResult HandleRegisterGuestForm(RegisterGuestForm registerGuestForm) { if (!this.ModelState.IsValid) { return(this.CurrentUmbracoPage()); } // no helper method on this.Members to register a user with a given memberType, so calling provider directly UmbracoMembershipProviderBase membersUmbracoMembershipProvider = (UmbracoMembershipProviderBase)Membership.Providers[Constants.Conventions.Member.UmbracoMemberProviderName]; MembershipCreateStatus membershipCreateStatus; MembershipUser membershipUser = membersUmbracoMembershipProvider.CreateUser( PartyGuest.Alias, // member type alias registerGuestForm.EmailAddress, // username registerGuestForm.Password, // password registerGuestForm.EmailAddress, // email null, // forgotten password question null, // forgotten password answer true, // is approved null, // provider user key out membershipCreateStatus); if (membershipCreateStatus != MembershipCreateStatus.Success) { switch (membershipCreateStatus) { case MembershipCreateStatus.DuplicateEmail: case MembershipCreateStatus.DuplicateUserName: this.ModelState.AddModelError("RegisterGuestValidation", "Email already registered"); break; } return(this.CurrentUmbracoPage()); } // cast from MembershipUser rather than use this.Members.GetCurrentMember() helper (which needs a round trip for the login) PartyGuest partyGuest = (PartyGuest)membershipUser; partyGuest.FacebookRegistration = false; // update database with member and party guid (duplicated data, but never changes) this.DatabaseContext.Database.Insert(new MemberPartyRow(partyGuest.Id, registerGuestForm.PartyGuid)); // (duplicate data) store party guid in cms cache partyGuest.PartyGuid = registerGuestForm.PartyGuid; // add member to DotMailer DotMailerService.GuestRegistrationStarted((Contact)partyGuest); // send cookie FormsAuthentication.SetAuthCookie(partyGuest.Username, true); //return this.NavigateToRegisterGuestUrl(registerGuestForm.PartyGuid); return(this.Redirect(this.Umbraco.TypedContentSingleAtXPath("//" + RegisterGuest.Alias).Url + "?partyGuid=" + registerGuestForm.PartyGuid.ToString())); }
public JsonResult HandlePartyDetailsForm(PartyDetailsForm partyDetailsForm) { FormResponse formResponse = new FormResponse(); if (this.ModelState.IsValid) { PartyHost partyHost = (PartyHost)this.Members.GetCurrentMember(); bool updateDotMailer = false; if (partyHost.PartyHeading != partyDetailsForm.PartyHeading) { partyHost.PartyHeading = partyDetailsForm.PartyHeading; } if (partyHost.PartyDateTime != partyDetailsForm.PartyDateTime) { partyHost.PartyDateTime = partyDetailsForm.PartyDateTime; updateDotMailer = true; } Address address = new Address( partyDetailsForm.Address1, partyDetailsForm.Address2, partyDetailsForm.TownCity, partyDetailsForm.Postcode); if (partyHost.PartyAddress.ToString() != address.ToString()) { partyHost.PartyAddress = address; updateDotMailer = true; } if (updateDotMailer) { DotMailerService.UpdatePartyDetails(partyHost); } formResponse.Success = true; } else { formResponse.Errors = this.ModelState.GetErrors(); } return(Json(formResponse, "text/plain")); }
private void CheckPartyPageComplete(PartyHost partyHost) { if (!partyHost.DotMailerPartyPageComplete) { if (partyHost.PartyImage != null && partyHost.FundraisingTarget > 0 && !string.IsNullOrWhiteSpace(partyHost.PartyAddress.ToString())) { partyHost.DotMailerPartyPageComplete = true; // update the host to indicate that their party page is now complete DotMailerService.UpdateContact((Contact)partyHost); } } }
/// <summary> /// a member can register, and skip the 2nd step /// if these values are then set afterwards when editing this profile, then we can then mark the registration as complete /// </summary> /// <param name="partier"></param> private void CheckRegistrationComplete(IPartier partier) { // once it has been completed, we never revert back, so only process if dot mailer thinks the host hasn't yet completed registration if (!partier.DotMailerRegistrationComplete) { if (!string.IsNullOrWhiteSpace(partier.FirstName) && !string.IsNullOrWhiteSpace(partier.LastName) && !string.IsNullOrWhiteSpace(partier.BillingAddress.ToString())) { if (partier is PartyHost) { DotMailerService.HostRegistrationCompleted((Contact)(PartyHost)partier); } else if (partier is PartyGuest) { DotMailerService.GuestRegistrationCompleted((Contact)(PartyGuest)partier); } } } }
public ActionResult HandleRegisterHostPartyKitForm(RegisterHostPartyKitForm registerHostPartyKitForm) { if (!ModelState.IsValid) { return(this.CurrentUmbracoPage()); } PartyHost partyHost = (PartyHost)this.Members.GetCurrentMember(); if (partyHost.FirstName != registerHostPartyKitForm.FirstName) { partyHost.FirstName = registerHostPartyKitForm.FirstName; } if (partyHost.LastName != registerHostPartyKitForm.LastName) { partyHost.LastName = registerHostPartyKitForm.LastName; } Address address = new Address( registerHostPartyKitForm.Address1, registerHostPartyKitForm.Address2, registerHostPartyKitForm.TownCity, registerHostPartyKitForm.PostCode); partyHost.PartyKitAddress = address; partyHost.PartyAddress = address; partyHost.BillingAddress = address; partyHost.TShirtSize = registerHostPartyKitForm.TShirtSize; partyHost.HasRequestedPartyKit = true; // update contact in DotMailer DotMailerService.HostRegistrationCompleted((Contact)partyHost); // mark as completed partyHost.DotMailerRegistrationComplete = true; //return this.CurrentUmbracoPage(); return(this.RedirectToCurrentUmbracoPage()); }
public ActionResult HandleRegisterHostForm(RegisterHostForm registerHostForm) { if (!this.ModelState.IsValid) { return(this.CurrentUmbracoPage()); } // no helper method on this.Members to register a user with a given memberType, so calling provider directly UmbracoMembershipProviderBase membersUmbracoMembershipProvider = (UmbracoMembershipProviderBase)Membership.Providers[Constants.Conventions.Member.UmbracoMemberProviderName]; MembershipCreateStatus membershipCreateStatus; MembershipUser membershipUser = membersUmbracoMembershipProvider.CreateUser( PartyHost.Alias, // member type alias registerHostForm.EmailAddress, // username registerHostForm.Password, // password registerHostForm.EmailAddress, // email null, // forgotten password question null, // forgotten password answer true, // is approved null, // provider user key out membershipCreateStatus); if (membershipCreateStatus != MembershipCreateStatus.Success) { switch (membershipCreateStatus) { case MembershipCreateStatus.DuplicateEmail: case MembershipCreateStatus.DuplicateUserName: this.ModelState.AddModelError("RegisterHostValidation", "Email already registered"); break; } return(this.CurrentUmbracoPage()); } // cast from MembershipUser rather than use this.Members.GetCurrentMember() helper (which needs a round trip for the login) PartyHost partyHost = (PartyHost)membershipUser; partyHost.FacebookRegistration = false; partyHost.MarketingSource = registerHostForm.MarketingSource; Guid partyGuid = Guid.NewGuid(); this.DatabaseContext.Database.Insert(new PartyRow(partyGuid)); // update database with member and party guid (duplicated data, but never changes) this.DatabaseContext.Database.Insert(new MemberPartyRow(partyHost.Id, partyGuid)); // (duplicate data) store party guid in cms cache partyHost.PartyGuid = partyGuid; // set the default custom url to be the party guid partyHost.PartyUrlIdentifier = partyGuid.ToString(); // set default party date partyHost.PartyDateTime = PartyHost.DefaultPartyDate; // add member to DotMailer DotMailerService.HostRegistrationStarted((Contact)partyHost); // send cookie FormsAuthentication.SetAuthCookie(partyHost.Username, true); // cause redirect, so that the login takes effect return(this.RedirectToCurrentUmbracoPage()); }
public ActionResult HandleRegisterGuestBillingForm(RegisterGuestBillingForm registerGuestBillingForm) { if (!this.ModelState.IsValid) { return(this.CurrentUmbracoPage()); } PartyGuest partyGuest = (PartyGuest)this.Members.GetCurrentMember(); if (partyGuest.FirstName != registerGuestBillingForm.FirstName) { partyGuest.FirstName = registerGuestBillingForm.FirstName; } if (partyGuest.LastName != registerGuestBillingForm.LastName) { partyGuest.LastName = registerGuestBillingForm.LastName; } Address address = new Address( registerGuestBillingForm.Address1, registerGuestBillingForm.Address2, registerGuestBillingForm.TownCity, registerGuestBillingForm.Postcode); partyGuest.BillingAddress = address; if (!string.IsNullOrWhiteSpace(registerGuestBillingForm.Message)) { // post message to party wall this.DatabaseContext.Database.Insert(new MessageRow() { MemberId = this.Members.GetCurrentMemberId(), Text = registerGuestBillingForm.Message, Image = null }); } if (registerGuestBillingForm.Amount == 0) { // update dot mailer to indicate guest has fully registered DotMailerService.GuestRegistrationCompleted((Contact)partyGuest); return(this.Redirect(partyGuest.PartyUrl)); } DonationRow donationRow = new DonationRow() { PartyGuid = registerGuestBillingForm.PartyGuid, Amount = registerGuestBillingForm.Amount, GiftAid = registerGuestBillingForm.AllowGiftAid, MemberId = this.Members.GetCurrentMemberId(), FirstName = registerGuestBillingForm.FirstName, LastName = registerGuestBillingForm.LastName, Address1 = registerGuestBillingForm.Address1, Address2 = registerGuestBillingForm.Address2, TownCity = registerGuestBillingForm.TownCity, Postcode = registerGuestBillingForm.Postcode, PaymentJourney = PaymentJourney.RegisterGuest, Success = false }; // insert new record this.DatabaseContext.Database.Insert(donationRow); // build new obj containing data for sage pay TransactionRegistrationRequest transactionRegistrationRequest = new TransactionRegistrationRequest(donationRow); // send to sage pay and get respone TransactionRegistrationResponse transactionRegistrationResponse = TransactionRegistration.Send(transactionRegistrationRequest); // based on response, we redirect the user to... if (transactionRegistrationResponse.Status == TransactionRegistrationStatus.OK) { // update database donationRow.VPSTxId = transactionRegistrationResponse.VPSTxId; donationRow.SecurityKey = transactionRegistrationResponse.SecurityKey; this.DatabaseContext.Database.Update(donationRow); return(this.Redirect(transactionRegistrationResponse.NextURL)); } this.ViewData["errorMessage"] = transactionRegistrationResponse.StatusDetail; return(this.View("RegisterGuest/Failed", this.CurrentPage)); }
public HttpResponseMessage Notifcation([FromBody] NotificationRequest notificationRequest) { // create response obj to send back to Sage Pay (defaulting to error) NotificationResponse notificationResponse = new NotificationResponse(); notificationResponse.Status = NotificationStatus.ERROR; // get associated transaction details from the database DonationRow donationRow = this.DatabaseContext.Database.Fetch <DonationRow>("SELECT TOP 1 * FROM wonderlandDonation WHERE VendorTxCode = @0", notificationRequest.VendorTxCode).Single(); // safety checks if (notificationRequest.VPSTxId != donationRow.VPSTxId) { notificationResponse.StatusDetail += "VPSTxID Invalid" + Environment.NewLine; } else if (!this.IsSignatureValid(donationRow, notificationRequest)) { notificationResponse.StatusDetail += "Signature Invalid" + Environment.NewLine; } else { // change response status from Error to OK, as valid inbound data is valid notificationResponse.Status = NotificationStatus.OK; switch (notificationRequest.Status) { case NotificationStatus.OK: donationRow.Success = true; this.SendPaymentConfirmationEmail(donationRow); break; case NotificationStatus.ABORT: donationRow.Cancelled = true; break; } this.DatabaseContext.Database.Update(donationRow); } // determine redirect url string redirectUrl = WebConfigurationManager.AppSettings["SagePay:RedirectDomain"]; switch (donationRow.PaymentJourney) { case PaymentJourney.RegisterGuest: // safety check (memberId should always have a value) if (donationRow.MemberId.HasValue) { // update dot mailer to indicate guest has fully registered DotMailerService.GuestRegistrationCompleted((Contact)(PartyGuest)this.Members.GetById(donationRow.MemberId.Value)); } redirectUrl += this.Umbraco.TypedContentSingleAtXPath("//" + RegisterGuest.Alias).Url; break; case PaymentJourney.Donate: redirectUrl += this.Umbraco.TypedContentSingleAtXPath("//" + Donate.Alias).Url; break; } //update dot mailer donation_amount and guest_count for associated party host DotMailerService.UpdateContact((Contact)this.Members.GetPartyHost(donationRow.PartyGuid)); notificationResponse.RedirectURL = redirectUrl; if (donationRow.Success) { notificationResponse.RedirectURL += "complete/"; } if (donationRow.Cancelled) { notificationResponse.RedirectURL += "cancelled/"; } notificationResponse.RedirectURL += "?VendorTxCode=" + notificationRequest.VendorTxCode; // ensure the return type is plain text return(new HttpResponseMessage(System.Net.HttpStatusCode.OK) { Content = new StringContent( SagePaySerializer.SerializeResponse(notificationResponse), Encoding.UTF8, "text/plain") }); }
public FormResponse RegisterGuest([FromUri] Guid partyGuid, [FromBody] FacebookCredentials facebookCredentials) { FormResponse formResponse = new FormResponse(); FacebookDetails facebookDetails = this.GetFacebookDetails(facebookCredentials); // no helper method on this.Members to register a user with a given memberType, so calling provider directly UmbracoMembershipProviderBase membersUmbracoMembershipProvider = (UmbracoMembershipProviderBase)Membership.Providers[Constants.Conventions.Member.UmbracoMemberProviderName]; MembershipCreateStatus membershipCreateStatus; MembershipUser membershipUser = membersUmbracoMembershipProvider.CreateUser( PartyGuest.Alias, // member type alias facebookDetails.EmailAddress, // username this.GetPassword(facebookDetails), // password facebookDetails.EmailAddress, // email null, // forgotten password question null, // forgotten password answer true, // is approved null, // provider user key out membershipCreateStatus); if (membershipCreateStatus != MembershipCreateStatus.Success) { switch (membershipCreateStatus) { case MembershipCreateStatus.DuplicateEmail: case MembershipCreateStatus.DuplicateUserName: this.ModelState.AddModelError("RegisterGuestValidation", "Email already registered"); formResponse.Errors = this.ModelState.GetErrors(); break; } return(formResponse); } // cast from MembershipUser rather than use this.Members.GetCurrentMember() helper (which needs a round trip for the login) PartyGuest partyGuest = (PartyGuest)membershipUser; partyGuest.FacebookRegistration = true; partyGuest.FirstName = facebookDetails.FirstName; partyGuest.LastName = facebookDetails.LastName; // update database with member and party guid (duplicated data, but never changes) this.DatabaseContext.Database.Insert(new MemberPartyRow(partyGuest.Id, partyGuid)); // (duplicate data) store party guid in cms cache partyGuest.PartyGuid = partyGuid; // add member to DotMailer DotMailerService.GuestRegistrationStarted((Contact)partyGuest); // send cookie FormsAuthentication.SetAuthCookie(partyGuest.Username, true); formResponse.Success = true; formResponse.Message = this.Umbraco.TypedContentSingleAtXPath("//" + Wonderland.Logic.Models.Content.RegisterGuest.Alias).Url; return(formResponse); }