Discussions
Registering for an event via SOAP API
almost 6 years ago by Austin Harmon
Hello,
I am attempting to register for an event and functions of the event via the SOAP API. I am able to get a cart line to show however the cart line for the event has red text saying:
"No registration option has been selected."
Here is my code:
CartData cart = null;
bool newCartCreated = false;
string EventId = "AHTEST";
string EventFunctionId = "A_MAIN";
string EventName = "Event Test";
RegistrationTypeData RTD = (RegistrationTypeData)3;
EntityManager entityManager = new EntityManager(uri, userName, password, EndpointType.Soap11);
CartManager cartManager = new CartManager(entityManager, partyId);
OptionEventFunctionDataCollection OEFDC = new OptionEventFunctionDataCollection();
OptionEventFunctionData OEFD = new OptionEventFunctionData
{
RegistrationType = RTD,
IsEventRegistrationOption = true
};
OEFDC.Add(OEFD);
EventData EventD = new EventData
{
EventId = EventId,
Name = EventName,
RegistrationType = RTD,
RegistrationOptions = OEFDC
};
EventSummaryData EventSumData = new EventSummaryData
{
EventId = EventId,
Name = EventName,
RegistrationType = RTD,
};
EventManager eventManager = new EventManager(entityManager, EventD);
//See if a cart is existing
QueryData query = new QueryData("Cart")
{
Criteria = new CriteriaDataCollection
{
CriteriaData.Equal("UserId", partyId)
}
};
FindResultsData queryResults = entityManager.Find(query);
if (queryResults.Result.Count > 0)
{
cart = (CartData)queryResults.Result[0];
linecount = cart.ComboOrder.Order.Lines.Count;
newCartCreated = false;
}
else
{
cartManager.DeleteCart();
cart = new CartData
{
UserId = partyId,
UpdateInformation = new EntityUpdateInformationData
{
CreatedBy = createdbyId,
CreatedOn = DateTime.UtcNow,
UpdatedBy = createdbyId,
UpdatedOn = DateTime.UtcNow
}
};
newCartCreated = true;
}
if (partyId != "")
{
var findResultsData =
entityManager.Find(
new QueryData(PartyCommercePreferencesData.EntityTypeName)
.AddCriteria(new CriteriaData("PartyId",
OperationData.Equal, partyId))).Result;
PartyCommercePreferencesData partyCommercePreferencesData = findResultsData[0] as PartyCommercePreferencesData;
var currency = partyCommercePreferencesData.DefaultCurrency;
var comboOrder = new ComboOrderData { Currency = currency };
OrderData order = comboOrder.Order = new OrderData { Currency = currency };
var partyCommPreferences = entityManager.FindByIdentity<PartyCommercePreferencesData>(partyId);
var customer = new CustomerPartyData { PartyId = partyId };
order.SoldToCustomerParty = customer;
comboOrder = cart.ComboOrder;
//add new product
order.Lines = new OrderLineDataCollection();
foreach (string item in productArray)
{
var line = new OrderLineData
{
Item = new ItemData { ItemId = item },
LineNumber = count,
QuantityOrdered = new QuantityData(1),
OrderLineId = linecount.ToString()
};
count++;
linecount++;
cart.ComboOrder.Order.Lines.Insert(index, line);
index++;
}
var line2 = new EventOrderLineData
{
Item = new EventItemData { ItemId = EventD.ToString() },
LineNumber = count,
QuantityOrdered = new QuantityData(1),
OrderLineId = linecount.ToString(),
Event = EventSumData
};
count++;
linecount++;
cart.ComboOrder.Order.Lines.Insert(index, line2);
index++;
index = 0;
eventManager.Register(partyId);
eventManager.RegistrationEventSettings(partyId);
eventManager.GetRegistrationData(partyId);
EventRegistrationData em = eventManager.GetRegistrationData(partyId);
ValidateResultsData vrdevent = eventManager.ValidateEventRegistration(em);
/*order.Delivery = new DeliveryDataCollection();
order.Delivery.Add(new DeliveryData
{
DeliveryMethod = new DeliveryMethodData { DeliveryMethodId = "UPS_GROUND" },
CustomerParty = customer,
//Address = new FullAddressData { Address = new AddressData { AddressLines = new AddressLineDataCollection { addressLines } } }
});*/
// DeliveryDataCollection deliverydata = order.Delivery;
//Validate will calculate pricing for us
var comboOrderValidation = entityManager.Validate(comboOrder);
comboOrder = comboOrderValidation.Entity;
cart.ComboOrder = comboOrder;
ValidateResultsData results = newCartCreated ? entityManager.Add(cart) : entityManager.Update(cart);
Response.Write(cart.CartId);
Response.Write(cart.ComboOrder.Order.Lines.Count.ToString());
}
else
{
Response.Write("Invalid PartyId");
}
}
}
}
So in summary I am attempting to register a user for an event and have filed EventData with EventId, Name, RegistrationType, and RegistrationOption
But am still getting this error about registration Option so if someone could explain what other properties are required that would be a big help.
Thank you.