public static XtracurEventsIndexMonthViewModel Build(XtracurDivision xtracurDivision, DateTime?month,
                                                             int?showImmediateEventId, int?showImmediateRecurrenceIndex)
        {
            var language = CultureHelper.CurrentLanguage;
            var firstDayOfCurrentMonth     = DateTimeHelper.GetFirstDayOfCurrentMonth();
            var firstDayOfChosenMonth      = DateTimeHelper.GetFirstDayOfMonth(month);
            var firstDayOfTheNextMonth     = DateTimeHelper.GetFirstDayOfTheNextMonth(firstDayOfChosenMonth);
            var firstDayOfThePreviousMonth = DateTimeHelper.GetFirstDayOfThePreviousMonth(firstDayOfChosenMonth);
            var eventGroupings             = EventsViewModelHelper.GetXtracurEventGroupings(xtracurDivision,
                                                                                            firstDayOfChosenMonth, firstDayOfTheNextMonth, showImmediateEventId, showImmediateRecurrenceIndex);

            return(new XtracurEventsIndexMonthViewModel
            {
                Alias = xtracurDivision.Alias,
                Title = xtracurDivision.GetNameByLanguage(language),
                IsCurrentMonthReferenceAvailable = firstDayOfCurrentMonth != firstDayOfChosenMonth,
                ChosenMonthDisplayText = GetMonthDisplayText(firstDayOfChosenMonth),
                PreviousMonthDisplayText = GetPreviousMonthDisplayText(firstDayOfThePreviousMonth),
                PreviousMonthDate = DateTimeHelper.GetDateStringForWeb(firstDayOfThePreviousMonth),
                NextMonthDisplayText = GetNextMonthDisplayText(firstDayOfTheNextMonth),
                NextMonthDate = DateTimeHelper.GetDateStringForWeb(firstDayOfTheNextMonth),
                EventGroupings = eventGroupings,
                ShowGroupingCaptions = eventGroupings.Count() > 1,
                HasEventsToShow = eventGroupings.Any(eg => eg.Events.Any(e => !e.IsShowImmediateHidden)),
                Breadcrumb = new Breadcrumb()
                {
                    BreadcrumbHelper.GetBreadcrumbRootItem(false),
                    BreadcrumbHelper.GetBreadcrumbXtracurEventsItem(xtracurDivision, true)
                }
            });
        }
        public new static XtracurEventsIndexWeekViewModel Build(XtracurDivision xtracurDivision, DateTime?fromDate,
                                                                int?showImmediateEventId, int?showImmediateRecurrenceIndex)
        {
            var language             = CultureHelper.CurrentLanguage;
            var weekFromDate         = DateTimeHelper.GetWeekStart(fromDate);
            var weekToDate           = weekFromDate.AddDays(7);
            var previousWeekFromDate = weekFromDate.AddDays(-7);
            var nextWeekFromDate     = weekFromDate.AddDays(7);
            var currentWeekFromDate  = DateTimeHelper.GetWeekStart(DateTime.Today);
            var events   = EventsViewModelHelper.GetXtracurEvents(xtracurDivision, weekFromDate, weekToDate, showImmediateEventId, showImmediateRecurrenceIndex).ToList();
            var weekDays = events.Where(e => e.Start >= weekFromDate)
                           .GroupBy(vm => vm.Start.Date)
                           .OrderBy(g => g.Key)
                           .Select(g => EventsDayViewModel.Build(g.Key, g.AsEnumerable()));
            var earlierEvents = events.Where(e => e.Start < weekFromDate);

            return(new XtracurEventsIndexWeekViewModel
            {
                Alias = xtracurDivision.Alias,
                Title = xtracurDivision.GetNameByLanguage(language),
                EarlierEvents = earlierEvents,
                Days = weekDays,
                WeekDisplayText = DateTimeHelper.GetWeekDisplayText(language, weekFromDate, weekToDate),
                PreviousWeekMonday = DateTimeHelper.GetDateStringForWeb(previousWeekFromDate),
                WeekMonday = DateTimeHelper.GetDateStringForWeb(weekFromDate),
                NextWeekMonday = DateTimeHelper.GetDateStringForWeb(nextWeekFromDate),
                IsCurrentWeekReferenceAvailable = (currentWeekFromDate != weekFromDate),
                HasEventsToShow = events.Any(e => !e.IsShowImmediateHidden),
                Breadcrumb = new Breadcrumb()
                {
                    BreadcrumbHelper.GetBreadcrumbRootItem(false),
                    BreadcrumbHelper.GetBreadcrumbXtracurEventsItem(xtracurDivision, true)
                }
            });
        }
Ejemplo n.º 3
0
        public ActionResult GetModalContents(int eventId, int?recurrenceIndex)
        {
            Event timeEvent = eventRepository.GetEventById(eventId);
            var   viewModel = EventsViewModelHelper.GetXtracurShowViewModel(timeEvent, recurrenceIndex ?? 0);

            return(PartialView(viewModel));
        }
Ejemplo n.º 4
0
        public ActionResult Index(string alias, DateTime?fromDate, int?showImmediateEventId, int?showImmediateRecurrenceIndex)
        {
            // Если получен showImmediateEventId, сделать редирект с корректными alias и fromDate,
            // поскольку они могли поменяться:
            if (showImmediateEventId.HasValue)
            {
                Event showImmediateTimeEvent = eventRepository.GetEventById(showImmediateEventId.Value);
                if (showImmediateTimeEvent != null)
                {
                    var showImmediateEventViewModel = EventsViewModelHelper.GetXtracurShowImmediateItemViewModel(
                        showImmediateTimeEvent, showImmediateRecurrenceIndex ?? 0);
                    if (!showImmediateEventViewModel.IsEmpty)
                    {
                        var showImmediateEventXtracurDivision = xtracurDivisionRepository.GetXtracurDivisionByAlias(showImmediateEventViewModel.DivisionAlias);
                        if (showImmediateEventXtracurDivision != null)
                        {
                            if (alias != showImmediateEventXtracurDivision.Alias || fromDate != showImmediateEventViewModel.FromDate)
                            {
                                return(RedirectToAction("Index",
                                                        new
                                {
                                    alias = showImmediateEventXtracurDivision.Alias,
                                    fromDate = showImmediateEventViewModel.FromDateString,
                                    showImmediateEventId = showImmediateEventId,
                                    showImmediateRecurrenceIndex = showImmediateRecurrenceIndex
                                }));
                            }
                        }
                    }
                }
            }
            // Основная логика:
            var xtracurDivision = xtracurDivisionRepository.GetXtracurDivisionByAlias(alias);

            if (xtracurDivision != null)
            {
                var viewModel = XtracurEventsIndexViewModelBase.Build(xtracurDivision, fromDate, showImmediateEventId,
                                                                      showImmediateRecurrenceIndex);
                return(View(viewModel.ViewName, viewModel));
            }
            return(HttpNotFound());
        }
Ejemplo n.º 5
0
 private static IEnumerable <XtracurEventItemViewModel> GetEvents(XtracurDivision xtracurDivision, string query, int offset,
                                                                  DateTime fromDate, DateTime toDate, out int totalCount)
 {
     return(EventsViewModelHelper.GetXtracurSearchEvents(xtracurDivision, fromDate, toDate, query, offset * ItemsOnPageCount, ItemsOnPageCount, out totalCount));
 }