public ActionResult RenderRegisterGuestBillingForm() { RegisterGuestBillingForm registerGuestBillingForm = new RegisterGuestBillingForm(); // set hidden field with party guid registerGuestBillingForm.PartyGuid = ((RegisterGuest)this.CurrentPage).PartyHost.PartyGuid; // set the default amount to the party host's suggested donation registerGuestBillingForm.Amount = this.Members.GetPartyHost(registerGuestBillingForm.PartyGuid).SuggestedDonation; PartyGuest partyGuest = (PartyGuest)this.Members.GetCurrentMember(); registerGuestBillingForm.FirstName = partyGuest.FirstName; registerGuestBillingForm.LastName = partyGuest.LastName; return(this.PartialView("RegisterGuest/Forms/RegisterGuestBillingForm", registerGuestBillingForm)); }
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)); }