Пример #1
0
        public ActionResult GetEventDetails(int id, int calendar, int type = 0)
        {
            EventLocation     l   = null;
            EventDetailsModel evm = null;
            var ms = Services.MemberService;

            if (type == 0)
            {
                //Fetch Event
                var e = EventService.GetEvent(id);

                //If it has a location fetch it
                if (e.locationId != 0)
                {
                    l = LocationService.GetLocation(e.locationId);
                }

                evm = new EventDetailsModel()
                {
                    CalendarId   = calendar,
                    Title        = e.title,
                    LocationId   = e.locationId,
                    Location     = l,
                    Descriptions = e.descriptions
                };
                if (null != e.start)
                {
                    evm.StartDate = ((DateTime)e.start).ToString("F", CultureInfo.CurrentCulture);
                }
                if (null != e.end)
                {
                    evm.EndDate = ((DateTime)e.end).ToString("F", CultureInfo.CurrentCulture);
                }
                if (e.Organisator != null && e.Organisator != 0)
                {
                    var member = ms.GetById(e.Organisator);
                    evm.Organisator = new Organisator()
                    {
                        Name = member.Name, Email = member.Email
                    };
                }
            }
            else if (type == 1)
            {
                var e = RecurringEventService.GetRecurringEvent(id);

                if (e.locationId != 0)
                {
                    l = LocationService.GetLocation(e.locationId);
                }

                Schedule schedule = new Schedule(new ScheduleWidget.ScheduledEvents.Event()
                {
                    Title                  = e.title,
                    DaysOfWeekOptions      = (DayOfWeekEnum)e.day,
                    FrequencyTypeOptions   = (FrequencyTypeEnum)e.frequency,
                    MonthlyIntervalOptions = (MonthlyIntervalEnum)e.monthly_interval
                });

                evm = new EventDetailsModel()
                {
                    CalendarId   = calendar,
                    Title        = e.title,
                    LocationId   = e.locationId,
                    Location     = l,
                    Descriptions = e.descriptions
                };

                if (null != e.start)
                {
                    var start = ((DateTime)schedule.NextOccurrence(DateTime.Now));
                    evm.StartDate = new DateTime(start.Year, start.Month, start.Day, e.start.Hour, e.start.Minute, 0).ToString("F", CultureInfo.CurrentCulture);
                }
                if (null != e.end)
                {
                    var end = ((DateTime)schedule.NextOccurrence(DateTime.Now));
                    evm.EndDate = new DateTime(end.Year, end.Month, end.Day, e.end.Hour, e.end.Minute, 0).ToString("F", CultureInfo.CurrentCulture);
                }
                if (e.Organisator != null && e.Organisator != 0)
                {
                    var member = ms.GetById(e.Organisator);
                    evm.Organisator = new Organisator()
                    {
                        Name = member.Name, Email = member.Email
                    };
                }
            }

            return(PartialView("EventDetails", evm));
        }
Пример #2
0
 public RecurringEvent GetById(int id)
 {
     return(RecurringEventService.GetRecurringEvent(id));
 }