Exemplo n.º 1
0
        public ServiceResult CreateEvent(Event e)
        {
            var result = new ServiceResult();

            try
            {
                if (ValidateEvent(e))
                {
                    _repository.Events.Create(e);

                    if (!_sharedRepository)
                        _repository.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                result.AddServiceError(Utilities.GetInnerMostException(ex));
            }

            return result;
        }
Exemplo n.º 2
0
        public EventOverview SetEventOverview(Event e)
        {
            var currentRegistrationFee = GetCurrentFeeForEvent(e.EventId, EventFeeType.Registration);

            var overview = new EventOverview
                {
                    EventId = e.EventId,
                    Location = string.Format("{0}, {1}", e.GeneralLocality, e.Region.Code),
                    Place = e.Place,
                    GeneralLocality = e.GeneralLocality,
                    Cost = currentRegistrationFee.Cost
                };

            if (e.EventDates.Count > 1)
                overview.Dates = string.Format("{0} - {1}", e.EventDates.Min(x => x.DateOfEvent).ToShortDateString(),
                                               e.EventDates.Max(x => x.DateOfEvent).ToShortDateString());
            else
                overview.Dates = e.EventDates.Min(x => x.DateOfEvent).ToShortDateString();

            return overview;
        }
Exemplo n.º 3
0
        public EventDetails SetEventDetail(Event e)
        {
            var overview = new EventDetails
                               {
                                   EventId = e.EventId,
                                   GeneralLocality = e.GeneralLocality,
                                   Place = e.Place,
                                   Address = e.Address1,
                                   City = e.Locality,
                                   State = e.Region.Name,
                                   StateCode = e.Region.Code,
                                   Zip = e.PostalCode,
                                   MetaDescription = e.MetaDescription,
                                   Latitude = e.Latitude,
                                   Longitude = e.Longitude,
                                   StartDate = e.EventDates.Min(x => x.DateOfEvent),
                                   EndDate = e.EventDates.Max(x => x.DateOfEvent),
                                   EventNews = e.EventDetails,
                                   RegistrationCutoff = this.IsRegistrationAvailable(e),
                                   EmailCutoff = this.IsEmailPacketOptionAvailable(e)
                               };
            IEnumerable<EventDateCounts> eventDates = _repository.Events.GetEventCounts(e.EventId);
            if (eventDates != null && eventDates.Count() > 0)
            {
                var ed = eventDates.FirstOrDefault();
                overview.RegistrationCount = ed.RegistrationCount;
                overview.MaxRegistrants = ed.MaxRegistrants;
            }
            var currentRegistrationFee = GetCurrentFeeForEvent(e.EventId, EventFeeType.Registration);
            overview.CurrentCost = currentRegistrationFee.Cost;
            overview.Sponsors = e.Sponsors;

            return overview;
        }
Exemplo n.º 4
0
 public ServiceResult RemoveEvent(Event e)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 5
0
 public bool IsRegistrationAvailable(Event e)
 {
     return IsRegistrationAvailable(e.RegistrationCutoff);
 }
Exemplo n.º 6
0
 public bool IsEmailPacketOptionAvailable(Event e)
 {
     return IsEmailPacketOptionAvailable(e.EmailCutoff);
 }
Exemplo n.º 7
0
        public ServiceResult CreateEventByTemplate(CreateNewEvent newEvent)
        {
            var result = new ServiceResult();

            try
            {
                EventTemplate template = GetEventTemplateById(newEvent.SelectedTemplateId);

                var e = new Event
                            {
                                GeneralLocality = newEvent.GeneralLocality,
                                RegionId = newEvent.RegionId,
                                Place = template.DefaultPlaceName,
                                IsActive = false
                            };

                int registrationTimeOffset = DirtyGirlServiceConfig.Settings.RegistrationCutoffHours * -1;
                e.RegistrationCutoff = newEvent.EventDate.AddHours(registrationTimeOffset);

                int emailPacketOffset = DirtyGirlServiceConfig.Settings.EmailPacketCutoffDays * -1;
                e.EmailCutoff = newEvent.EventDate.AddDays(emailPacketOffset);

                ServiceResult saveEventResult = CreateEvent(e);
                ServiceResult generateDateResult = GenerateEventDate(e.EventId, newEvent.EventDate, template.StartTime,
                                                                     template.EndTime, template.WaveDuration,
                                                                     template.MaxRegistrantsPerWave);
                var feeResult = new ServiceResult();

                var rfee = new EventFee
                               {
                                   EventId = e.EventId,
                                   EffectiveDate = DateTime.Now.Date,
                                   Cost = template.DefaultRegistrationCost,
                                   EventFeeType = EventFeeType.Registration,
                                   Discountable = true,
                                   Taxable = true
                               };
                var tFee = new EventFee
                               {
                                   EventId = e.EventId,
                                   EffectiveDate = DateTime.Now.Date,
                                   Cost = template.DefaultTransferFeeCost,
                                   EventFeeType= EventFeeType.Transfer,
                                   Discountable = false,
                                   Taxable = false
                               };
                var chFee = new EventFee
                                {
                                    EventId = e.EventId,
                                    EffectiveDate = DateTime.Now.Date,
                                    Cost = template.DefaultChangeFeeCost,
                                    EventFeeType = EventFeeType.ChangeEvent,
                                    Discountable = false,
                                    Taxable = false
                                };
                var cfee = new EventFee
                               {
                                   EventId = e.EventId,
                                   EffectiveDate = DateTime.Now.Date,
                                   Cost = template.DefaultCancellationFeeCost,
                                   EventFeeType = EventFeeType.Cancellation,
                                   Discountable = false,
                                   Taxable = false
                               };

                var pfee = new EventFee
                {
                    EventId = e.EventId,
                    EffectiveDate = DateTime.Now.Date,
                    Cost = template.DefaultProcessingFeeCost,
                    EventFeeType = EventFeeType.ProcessingFee,
                    Discountable = false,
                    Taxable = false
                };

                var sfee = new EventFee
                {
                    EventId = e.EventId,
                    EffectiveDate = DateTime.Now.Date,
                    Cost = template.DefaultShippingFeeCost,
                    EventFeeType = EventFeeType.Shipping,
                    Discountable = false,
                    Taxable = false
                };

                CreateEventFee(rfee);
                CreateEventFee(tFee);
                CreateEventFee(chFee);
                CreateEventFee(cfee);
                CreateEventFee(sfee);
                CreateEventFee(pfee);

                foreach (EventTemplate_PayScale ps in template.PayScales)
                {
                    var eventStart = newEvent.EventDate;

                    eventStart = newEvent.EventDate.AddDays(-1*ps.DaysOut);

                    // for registrations,
                    if (ps.EventFeeType == EventFeeType.Registration)
                    {
                        while (eventStart.DayOfWeek != DayOfWeek.Wednesday)
                            eventStart = eventStart.AddDays(1);
                    }
                    var newFee = new EventFee
                                     {
                                         EventId = e.EventId,
                                         EffectiveDate = eventStart.Date,
                                         Cost = ps.Cost,
                                         EventFeeType = ps.EventFeeType,
                                         Taxable = ps.Taxable,
                                         Discountable = ps.Discountable
                                     };

                    feeResult = CreateEventFee(newFee);

                    if (!feeResult.Success)
                        break;
                }

                if (saveEventResult.Success && generateDateResult.Success && feeResult.Success)
                {
                    _repository.SaveChanges();
                    newEvent.EventId = e.EventId;
                }
                else
                    result.AddServiceError("An Error Occured Creating this Event");
            }
            catch (Exception ex)
            {
                result.AddServiceError(Utilities.GetInnerMostException(ex));
            }

            return result;
        }
Exemplo n.º 8
0
        private bool ValidateEvent(Event eventToValidate)
        {
            const bool isValid = true;

            return isValid;
        }