// GET: Admin public ActionResult Index() { if (Globals.IS_ADMIN) { AdminHomeVM model = new AdminHomeVM(); GetDAL get = new GetDAL(); get.OpenConnection(); model.LstAllGroups = get.GetAllGroups(); model.LstAllEvents = get.GetAllEvents(); model.LstAdminEvents = get.GetAdminEventsByUser(Globals.LOGGED_IN_USER.IntUserID); foreach (Event e in model.LstAdminEvents) { e.LstRehearsalParts = get.GetRehearsalPartsByEvent(e); foreach (RehearsalPart rp in e.LstRehearsalParts) { rp.LstMembers = get.GetUsersByRehearsalPart(rp); if (rp.DtmStartDateTime.Equals(DateTime.MinValue)) { rp.DtmStartDateTime = null; } if (rp.DtmEndDateTime.Equals(DateTime.MinValue)) { rp.DtmEndDateTime = null; } } } model.LstAllTypes = get.GetAllTypes(); model.LstAllUsersForAdminEvents = get.GetAllUsersForAdminEvents(model.LstAdminEvents); get.CloseConnection(); get.OpenConnection(); foreach (Users u in model.LstAllUsersForAdminEvents) { u.LstConflicts = get.GetConflictsByUser(u).OrderBy(x => x.DtmStartDateTime).ToList(); } get.CloseConnection(); return(View("AdminHome", model)); } else { return(RedirectToAction("Index", "Home")); } }