Ejemplo n.º 1
0
        public void TestAddDate_DisablePricingSchedule()
        {
            var occurrence = new EventOccurrence() { Event = new Event() };
            occurrence.AddOccurrenceDate(new DateTime(2000, 1, 1), new DateTime(2000, 1, 2));

            var earlySchedule = new PricingSchedule(10M, new DateTime(1999, 01, 01));
            occurrence.SetEarlyRegistrationPrice(earlySchedule);

            var lateSchedule = new PricingSchedule(10M, new DateTime(1999, 12, 01));
            occurrence.SetEarlyRegistrationPrice(earlySchedule);

            occurrence.EnablePricingSchedule();

            occurrence.AddOccurrenceDate(new DateTime(1999, 12, 30), new DateTime(1999, 12, 31));

            Assert.IsFalse(occurrence.IsPriceScheduleEnabled);
        }
 public static void SetPricingSchedule(EventOccurrenceV2 source, EventOccurrence target)
 {
     //Must do this after setting early and late cost
     if (GetBooleanValue(source.IsPriceScheduleEnabled))
     {
         target.EnablePricingSchedule();
     }
     else
     {
         target.DisablePricingSchedule();
     }
 }
Ejemplo n.º 3
0
        public void TestCalculateCost_EarlyAbsolute()
        {
            var earlyCuttofDate = new DateTime(2000, 1, 1);
            var defaultCost = 10M;
            var earlyCost = 5M;
            var ev = new Event();
            ev.Cost = defaultCost;
            var occurrence = new EventOccurrence() { Event = ev, Cost = defaultCost };
            occurrence.AddOccurrenceDate(new DateTime(2000, 3, 1), new DateTime(2000, 3, 2));
            var earlySchedule = new PricingSchedule(earlyCost, earlyCuttofDate);
            occurrence.SetEarlyRegistrationPrice(earlySchedule);

            occurrence.EnablePricingSchedule();

            Assert.AreEqual(earlyCost, occurrence.CalculateCost(earlyCuttofDate.AddDays(-1)));
            Assert.AreEqual(earlyCost, occurrence.CalculateCost(earlyCuttofDate));
            Assert.AreEqual(defaultCost, occurrence.CalculateCost(earlyCuttofDate.AddDays(1)));

            occurrence.DisablePricingSchedule();

            Assert.AreEqual(defaultCost, occurrence.CalculateCost(earlyCuttofDate.AddDays(-1)));
            Assert.AreEqual(defaultCost, occurrence.CalculateCost(earlyCuttofDate));
            Assert.AreEqual(defaultCost, occurrence.CalculateCost(earlyCuttofDate.AddDays(1)));
        }
Ejemplo n.º 4
0
 public void TestEnablePricingSchedule_NoSchedules()
 {
     var ev = new Event();
     var occurrence = new EventOccurrence() { Event = ev };
     occurrence.EnablePricingSchedule();
 }
Ejemplo n.º 5
0
        public void TestEnablePricingSchedule_LateSpecified()
        {
            var ev = new Event();
            var occurrence = new EventOccurrence() { Event = ev };
            var pricingSchedule = new PricingSchedule(10M, 30);
            occurrence.SetLateRegistrationPrice(pricingSchedule);
            occurrence.EnablePricingSchedule();

            Assert.IsTrue(occurrence.IsPriceScheduleEnabled);
        }
Ejemplo n.º 6
0
        public void TestEnablePricingSchedule()
        {
            var ev = new Event();
            var occurrence = new EventOccurrence() { Event = ev };
            var earlySchedule = new PricingSchedule(10M, 30);
            occurrence.SetEarlyRegistrationPrice(earlySchedule);
            var lateSchedule = new PricingSchedule(20M, 30);
            occurrence.SetLateRegistrationPrice(lateSchedule);
            occurrence.EnablePricingSchedule();

            Assert.IsTrue(occurrence.IsPriceScheduleEnabled);
        }
Ejemplo 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)));
        }
Ejemplo n.º 8
0
        public void TestCalculateCost_LateAbsolute()
        {
            var lateDate = new DateTime(2000, 1, 1);
            var defaultCost = 10M;
            var lateCost = 15M;
            var ev = new Event();
            var occurrence = new EventOccurrence() { Event = ev };
            occurrence.AddOccurrenceDate(lateDate.AddDays(30), lateDate.AddDays(31));
            occurrence.Cost = defaultCost;
            var lateSchedule = new PricingSchedule(lateCost, lateDate);
            occurrence.SetLateRegistrationPrice(lateSchedule);

            occurrence.EnablePricingSchedule();

            Assert.AreEqual(defaultCost, occurrence.CalculateCost(lateDate.AddDays(-1)));
            Assert.AreEqual(lateCost, occurrence.CalculateCost(lateDate));
            Assert.AreEqual(lateCost, occurrence.CalculateCost(lateDate.AddDays(1)));

            occurrence.DisablePricingSchedule();

            Assert.AreEqual(defaultCost, occurrence.CalculateCost(lateDate.AddDays(-1)));
            Assert.AreEqual(defaultCost, occurrence.CalculateCost(lateDate));
            Assert.AreEqual(defaultCost, occurrence.CalculateCost(lateDate.AddDays(1)));
        }
        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;
        }