public IActionResult Index(Guid?userId = null, DateTime?startDate = null, DateTime?endDate = null, int?offset = null) { ViewData["WideForm"] = true; DateTime startDateFilter = startDate ?? new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1); DateTime endDateFilter = endDate ?? startDateFilter.AddMonths(1).AddDays(-1); // gets around figuring out what the last day of the month is if (offset != null) { startDateFilter = startDateFilter.AddMonths(offset.Value); endDateFilter = endDateFilter.AddMonths(offset.Value); // redirect to avoid odd behavior with querystring return(new RedirectToActionResult("Index", "Calendar", new { UserId = userId, StartDate = startDateFilter, EndDate = endDateFilter })); } string monthName = startDateFilter.ToString("MMMM"); ViewData["MonthName"] = monthName; ViewData["Title"] = "Calendar - " + monthName; Guid?currentUserId = loginService.GetCurrentUserId(); ViewData["OtherUserName"] = null; if (userId != null && userId != currentUserId) { ViewData["OtherUserName"] = userService.Get(userId.Value).FriendlyName; } // some of this stuff reacts poorly to being read via QueryString in view so we avoid it ViewData["UserId"] = userId ?? loginService.GetCurrentUserId(); ViewData["StartDate"] = startDateFilter; ViewData["EndDate"] = endDateFilter; ViewData["UserDropDown"] = happeningService.GetUserDictionary(true, false); ViewData["LastDayOfMonth"] = GetEndOfMonth(startDateFilter).Day; ViewData["MonthStartOffset"] = (int)GetBeginningOfMonth(startDateFilter).DayOfWeek; // lets us adjust when weeks start/end based on what day the month started at IEnumerable <IEnumerable <HappeningDto> > data; try { data = ApiGetFiltered(true, userId, startDateFilter, endDateFilter); } catch (ArgumentException ae) { ViewData["Error"] = ae.Message; return(View()); } return(View(data)); }
public Dictionary <Guid, string> ApiGetPossibleUsers() { return(happeningService.GetUserDictionary()); }