private static void SetDefaultRegistrationDates(EventOccurrence occurrence, DateRange occurrenceDate)
        {
            DateTime startDate = DateTime.UtcNow.Date;
            if (occurrenceDate.Start.Date <= DateTime.UtcNow.Date)
                startDate = occurrenceDate.Start.Date.AddDays(-1);

            DateTime endDate = occurrenceDate.End.Date;
            occurrence.SetRegistrationDates(startDate, endDate);
        }
        public static void SetRegistrationDates(EventOccurrenceV2 source, EventOccurrence target)
        {
            if (string.IsNullOrEmpty(source.RegistrationStartDate))
                return;

            var start = GetDateTime(source.RegistrationStartDate);
            var end = GetDateTime(source.RegistrationEndDate);

            target.SetRegistrationDates(start, end);
        }
Exemplo n.º 3
0
        public void TestSetRegistrationDates_StartEndSame()
        {
            var ev = new Event();
            var occurrence = new EventOccurrence() { Event = ev };

            occurrence.SetRegistrationDates(new DateTime(2000, 1, 1), new DateTime(2000, 1, 1));
        }
Exemplo n.º 4
0
        public void TestSetRegistrationDates()
        {
            var ev = new Event();
            var occurrence = new EventOccurrence() { Event = ev };

            occurrence.SetRegistrationDates(new DateTime(2000, 1, 1), new DateTime(2000, 1, 2));

            Assert.AreEqual(occurrence.RegistrationStartDate, new DateTime(2000, 1, 1));
            Assert.AreEqual(occurrence.RegistrationEndDate, new DateTime(2000, 1, 2));
        }
Exemplo n.º 5
0
        public void TestEffectiveRegistrationStartDate()
        {
            var ev = new Event();
            ev.PublishDate = new DateTime(2000, 1, 1);

            var occurrence = new EventOccurrence() { Event = ev };

            Assert.AreEqual(new DateTime(2000, 1, 1), occurrence.EffectiveRegistrationStartDate);

            occurrence.SetRegistrationDates(new DateTime(2000, 1, 2), null);

            Assert.AreEqual(new DateTime(2000, 1, 2), occurrence.EffectiveRegistrationStartDate);
        }
Exemplo n.º 6
0
        public void TestEffectiveRegistrationEndDate()
        {
            var ev = new Event();
            var occurrence = new EventOccurrence() { Event = ev };
            occurrence.AddOccurrenceDate(new DateTime(2000, 1, 1), new DateTime(2000, 1, 2));
            occurrence.AddOccurrenceDate(new DateTime(1999, 12, 30), new DateTime(1999, 12, 31));

            var expectedEffectiveRegistrationEndDate = new DateTime(1999, 12, 29); //day before start date
            Assert.AreEqual(expectedEffectiveRegistrationEndDate, occurrence.EffectiveRegistrationEndDate);

            occurrence.SetRegistrationDates(null, new DateTime(1999, 12, 15));

            expectedEffectiveRegistrationEndDate = new DateTime(1999, 12, 15);
            Assert.AreEqual(expectedEffectiveRegistrationEndDate, occurrence.EffectiveRegistrationEndDate);
        }
Exemplo n.º 7
0
        public void TestCalculateCost_LateRelative()
        {
            var firstOccurrenceDate = new DateTime(2000, 1, 1);
            var lateDays = 5;
            var defaultCost = 10M;
            var lateCost = 15M;
            var ev = new Event();
            var occurrence = new EventOccurrence() { Event = ev };
            occurrence.AddOccurrenceDate(firstOccurrenceDate, firstOccurrenceDate.AddHours(1));
            occurrence.Cost = defaultCost;
            var lateSchedule = new PricingSchedule(lateCost, lateDays);
            occurrence.SetLateRegistrationPrice(lateSchedule);
            occurrence.SetRegistrationDates(null, firstOccurrenceDate.AddDays(-1));

            occurrence.EnablePricingSchedule();

            Assert.AreEqual(defaultCost, occurrence.CalculateCost(firstOccurrenceDate.AddDays(-6)));
            Assert.AreEqual(lateCost, occurrence.CalculateCost(firstOccurrenceDate.AddDays(-5)));
            Assert.AreEqual(lateCost, occurrence.CalculateCost(firstOccurrenceDate.AddDays(-4)));

            occurrence.DisablePricingSchedule();

            Assert.AreEqual(defaultCost, occurrence.CalculateCost(firstOccurrenceDate.AddDays(-6)));
            Assert.AreEqual(defaultCost, occurrence.CalculateCost(firstOccurrenceDate.AddDays(-5)));
            Assert.AreEqual(defaultCost, occurrence.CalculateCost(firstOccurrenceDate.AddDays(-4)));
        }
        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;
        }