public void TestSetEventIdInvalidValue() { var occurrence = new EventOccurrence(); occurrence.SetEventId(0); }
public static void SetEvent(ObjectContext context, EventOccurrenceV2 source, EventOccurrence target) { int eventId = -1; Event theEvent = null; if (int.TryParse(source.EventId, out eventId)) { theEvent = context.CreateObjectSet<Event>().SingleOrDefault(e => e.Id == eventId); } else if (!string.IsNullOrEmpty(source.EventExternalId)) { var mapping = context.CreateObjectSet<DataImportEntityIdMap>().SingleOrDefault(m => m.ExternalId == source.EventExternalId && m.EntityName == "Event"); if (mapping != null) { theEvent = context.CreateObjectSet<Event>().Single(e => e.Id == mapping.InternalId); } } if (theEvent == null) { throw new BusinessException("Cannot find the event based on the EventId or the EventExternalId"); } target.Event = theEvent; target.SetEventId(theEvent.Id); }
public static EventOccurrence BuildNewOccurrence(ObjectContext objectContext, int newEventId, EventOccurrence item) { var newOccurrence = new EventOccurrence { ContactName = item.ContactName, ContactEmail = item.ContactEmail, ContactPhone = item.ContactPhone, ContactPhoneExtension = item.ContactPhoneExtension, Cost = item.Cost, CostCenter = item.CostCenter, OrgUnitId = item.OrgUnitId, MaximumAttendees = item.MaximumAttendees, LastUpdated = System.DateTime.UtcNow, PaymentProcessorConfigurationId = item.PaymentProcessorConfigurationId, IsRegistrationEnabled = item.IsRegistrationEnabled, IsNotificationListEnabled = item.IsNotificationListEnabled, IsNotifyContactEnabled = item.IsNotifyContactEnabled, SpecialInstructions = item.SpecialInstructions, LocationOrgUnitId = item.LocationOrgUnitId, LocationName = item.LocationName, Address1 = item.Address1, Address2 = item.Address2, City = item.City, PostalCode = item.PostalCode, StateId = item.StateId, CountryId = item.CountryId, Latitude = item.Latitude, Longitude = item.Longitude, IsGuestDemographicInfoRequired = item.IsGuestDemographicInfoRequired }; newOccurrence.SetPresenter(item.Presenter); newOccurrence.SetIsEnabled(item.IsEnabled); newOccurrence.SetEventId(newEventId); newOccurrence.SetAddress1(item.Address1); newOccurrence.SetAddress2(item.Address2); newOccurrence.SetRegistrationDates(item.RegistrationStartDate, item.RegistrationEndDate); if (item.IsPriceScheduleEnabled) newOccurrence.EnablePricingSchedule(); else newOccurrence.DisablePricingSchedule(); CaptureCostScheduleData(item, newOccurrence); objectContext.AddObject("EventOccurrences", newOccurrence); objectContext.SaveChanges(); //event occurrence documents foreach (var doc in item.EventOccurrencesDocuments) { var newDoc = new EventOccurrencesDocument() { DocumentPath = doc.DocumentPath, EventOccurrence = newOccurrence }; newOccurrence.EventOccurrencesDocuments.Add(newDoc); } //event occurrence dates foreach (var dateItem in item.EventOccurrenceDates) { newOccurrence.AddOccurrenceDate(dateItem.StartDate, dateItem.EndDate); } objectContext.SaveChanges(); return newOccurrence; }