public ActionResult HandleDonateForm(DonateForm donateForm) { if (!this.ModelState.IsValid) { return(this.CurrentUmbracoPage()); } int?memberId = null; if (this.Members.IsLoggedInPartier()) { memberId = this.Members.GetCurrentMemberId(); } DonationRow donationRow = new DonationRow() { PartyGuid = donateForm.PartyGuid, Amount = donateForm.Amount, GiftAid = donateForm.AllowGiftAid, MemberId = memberId, FirstName = donateForm.FirstName, LastName = donateForm.LastName, Address1 = donateForm.Address1, Address2 = donateForm.Address2, TownCity = donateForm.TownCity, Postcode = donateForm.Postcode, PaymentJourney = PaymentJourney.Donate, 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("Donate/Failed", this.CurrentPage)); }
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)); }