here is my code:
it gets loaded after the user clicks the link for the EVENT they want to register for., the redirect at the end goes to the CART page.
it works the first time around , I get to the cart page and see what I just selected , then if the user hits "Register for a different event" it goes back to the Event Selection page as expected and when the user selects a second event to register for they get redirected to the Cart page again (as expected) but the subsequent EVENT is not reflected on the page. Only the first Event selected is shown. However, The Cart Tables in iMIS are populated correctly.
In order for the second event to reflect in the cart, I need to log out the user and log back in.
Any thoughts, Greatly Appreciated!!
Here is the code (sorry it's in VB...) :-)
Imports
Asi.Security
Imports
Asi.iBO
Imports
Asi.iBO.ContactManagement
Imports
Asi.iBO.Events
Imports
Asi.iBO.Commerce
Imports
Asi.iBO.Financials
Imports
Asi.Web
Imports
AccountManagement
Imports
Asi.Membership
Imports
Asi.BaeImports System.Data.SqlClient
On Page Load:
Dim _id As String = ""
If (Asi.Security.AppPrincipal.CurrentIdentity.IsAuthenticated And Asi.Security.AppPrincipal.CurrentIdentity.ContactMaster <> "") Then
_id = Asi.Security.AppPrincipal.CurrentIdentity.ContactMaster
End If
Dim user As CContactUser = Nothing
user = CContactUser.LoginByWebLogin(Asi.Security.AppPrincipal.CurrentIdentity.LoginName)
user.Validate()
Dim user1 As IiMISUser = DirectCast(user, IiMISUser)Dim _eventcode As String = Request.QueryString("iKey")Dim contact As New CContact(user, user.ContactId)If _eventcode IsNot Nothing Then
lblWhat.Text =
lblWho.Text =
Dim _event As New CEvent(user1, _eventcode)"Registration for " & _event.Title"Registrant: " & contact.FullNameEnd If
cartevent = myCart.NewCartEvent(_eventcode, _id,
cartFunc.CartEventID = cartevent.CartEventId
cartFunc.FunctionCode = _eventcode &
cartFunc.Quantity = 1
cartFunc.Title = cartevent.Title
cartFunc.Price = thePrice
cartevent.AddCartEventFunction(cartFunc)
myeventInfo.Id = _id
myeventInfo.EventCode = _eventcode
myeventInfo.UserId = _id
myeventInfo.Class =
Dim myCart As New Asi.Bae.Business.Cart.Cart(_id)Dim myEvent As New CEvent(user1, _eventcode)Dim myFunction As New CFunction(user1, myEvent, _eventcode)Dim thePrice As Decimal = myFunction.GetFuncFeeByRegClass("ERPA").RegularFeeDim _curAddr As CAddress = contact.GetAddressByPurpose("Address")Dim cartevent As Asi.Bae.Business.Cart.CartEventDim cartFunc As New Asi.Bae.Business.Cart.CartEventFunction"ERPA")"/" & _eventcodeDim myeventInfo As Asi.Bae.Business.Events.RegistrantInformation = cartevent.AddRegistrant()"ERPA"
myeventInfo.FirstName = contact.FirstName
myeventInfo.LastName = contact.LastName
myeventInfo.Address1 = _curAddr.Address1
myeventInfo.City = _curAddr.City
myeventInfo.State = _curAddr.StateProvince
myeventInfo.PostalCode = _curAddr.PostalCode
myeventInfo.PermanentChange =
False
myeventInfo.AddressPurpose =
"Address"
myeventInfo.Phone = contact.WorkPhone
myeventInfo.Email = contact.EmailAddress
cartevent.Complete =
Dim iDunno As Boolean = myeventInfo.SaveRegistrantTrue
myCart.Save(cartevent)
myCart.Dispose()
cartevent.Dispose()
cartFunc.Dispose()
myeventInfo.Dispose()
Msg.Text =
Catch ex As Exception"Error: " + ex.MessageEnd Try
Response.Redirect(
"http://dnntest.asppa.org/imis15/erpaexam.org/Store/Cart/Core/cart/MyCart.aspx")End Sub
REPOSTING CODE...
I noticed my code was hard to read, hopefully this is better...
Imports Asi.Security
Imports Asi.iBO
Imports Asi.iBO.ContactManagement
Imports Asi.iBO.Events
Imports Asi.iBO.Commerce
Imports Asi.iBO.Financials
Imports Asi.Web
Imports AccountManagement
Imports Asi.Membership
Imports Asi.Bae
Imports System.Data.SqlClient
Partial Public Class ErpaEventRegis
Inherits System.Web.UI.UserControl
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Try
Dim _id As String = ""
If (Asi.Security.AppPrincipal.CurrentIdentity.IsAuthenticated And Asi.Security.AppPrincipal.CurrentIdentity.ContactMaster <> "") Then
_id = Asi.Security.AppPrincipal.CurrentIdentity.ContactMaster
End If
' ** NOT SURE IF THERE IS A WAY AROUND THIS *** ??
Dim user As CContactUser = Nothing
user = CContactUser.LoginByWebLogin(Asi.Security.AppPrincipal.CurrentIdentity.LoginName)
Dim user1 As IiMISUser = DirectCast(user, IiMISUser)
Dim _eventcode As String = Request.QueryString("iKey")
Dim contact As New CContact(user, user.ContactId)
If _eventcode IsNot Nothing Then
Dim _event As New CEvent(user1, _eventcode)
lblWhat.Text = "Registration for " & _event.Title
lblWho.Text = "Registrant: " & contact.FullName
End If
Dim myCart As New Asi.Bae.Business.Cart.Cart(_id)
Dim myEvent As New CEvent(user1, _eventcode)
Dim myFunction As New CFunction(user1, myEvent, _eventcode)
Dim thePrice As Decimal = myFunction.GetFuncFeeByRegClass("ERPA").RegularFee
Dim _curAddr As CAddress = contact.GetAddressByPurpose("Address")
Dim cartevent As Asi.Bae.Business.Cart.CartEvent
Dim cartFunc As New Asi.Bae.Business.Cart.CartEventFunction
cartevent = myCart.NewCartEvent(_eventcode, _id, "ERPA")
cartFunc.CartEventID = cartevent.CartEventId
cartFunc.FunctionCode = _eventcode & "/" & _eventcode
cartFunc.Quantity = 1
cartFunc.Title = cartevent.Title
cartFunc.Price = thePrice
cartevent.AddCartEventFunction(cartFunc)
Dim myeventInfo As Asi.Bae.Business.Events.RegistrantInformation = cartevent.AddRegistrant()
myeventInfo.Id = _id
myeventInfo.EventCode = _eventcode
myeventInfo.UserId = _id
myeventInfo.Class = "ERPA"
myeventInfo.FirstName = contact.FirstName
myeventInfo.LastName = contact.LastName
myeventInfo.Address1 = _curAddr.Address1
myeventInfo.City = _curAddr.City
myeventInfo.State = _curAddr.StateProvince
myeventInfo.PostalCode = _curAddr.PostalCode
myeventInfo.PermanentChange = False
myeventInfo.AddressPurpose = "Address"
myeventInfo.Phone = contact.WorkPhone
myeventInfo.Email = contact.EmailAddress
Dim iDunno As Boolean = myeventInfo.SaveRegistrant
cartevent.Complete = True
myCart.Save(cartevent)
myCart.Dispose()
cartevent.Dispose()
cartFunc.Dispose()
myeventInfo.Dispose()
Catch ex As Exception
Msg.Text = "Error: " + ex.Message
End Try
Response.Redirect("http://dnntest.asppa.org/imis15/erpaexam.org/Store/Cart/Core/cart/MyCart.aspx")
End Sub