Exemplo n.º 1
0
        public ActionResult Holidays(EventDataFilter vm)
        {
            Func <IQueryable <Holiday>, IQueryable <Holiday> > holidayFilter = q =>
            {
                if (vm.start.HasValue)
                {
                    q = q.Where(t => t.Date >= vm.start.Value);
                }

                if (vm.start.HasValue)
                {
                    q = q.Where(t => t.Date <= vm.end.Value);
                }

                return(q);
            };

            var holidays = _holidayRepository.Search(holidayFilter);

            var payload = holidays.Select(h => new EventData
            {
                id     = h.Id,
                allDay = true,
                title  = h.Title + "-" + Enum.GetName(typeof(HolidayType), h.Type) + "-Holiday",
                start  = h.Date.ToString("s"),
                end    = h.Date.ToString("s")
            }).ToList();

            return(Json(payload, JsonRequestBehavior.AllowGet));
        }