Пример #1
0
        public ActionResult List(string mockUser = "")
        {
            if (!(Roles.IsUserInRole("Administrator") || Roles.IsUserInRole("Job Coach") || Roles.IsUserInRole("Parent")))
            {
                Response.Redirect("~/Unauthorized");
                return(View());
            }

            string thisUsername = AccountHelper.getCurrentUsername();

            if (Roles.IsUserInRole("Administrator"))
            {
                if (mockUser == null || mockUser.Equals("") || !accountHelper.userExists(mockUser))
                {
                    //What should Admin see? A user select to continue?
                    ViewData["JobCoaches"] = accountHelper.getListOfUsersInRole("Job Coach");
                    ViewData["Parents"]    = accountHelper.getListOfUsersInRole("Parent");
                    ViewData["mockUser"]   = "";
                }
                else
                {
                    ViewData["mockUser"] = mockUser;
                    ViewData["Routines"] = helper.getMostRecentRoutines(mockUser);
                }
            }
            else //user is jobcoach or parent
            {
                ViewData["Routines"] = helper.getMostRecentRoutines();
            }

            return(View());
        }
Пример #2
0
        public ActionResult ListRoutines(string mockUser = "")
        {
            if (!(Roles.IsUserInRole("Administrator") || Roles.IsUserInRole("Job Coach") || Roles.IsUserInRole("Parent")))
            {
                Response.Redirect("~/Unauthorized");
                return(View());
            }

            List <Routine> allRoutines;

            if (Roles.IsUserInRole("Administrator"))
            {
                if (mockUser == null || mockUser.Equals("") || !accountHelper.userExists(mockUser))
                {
                    return(RedirectToAction("Index", "Job"));
                }

                ViewData["mockUser"] = mockUser;

                allRoutines = routineHelper.getMostRecentRoutines(mockUser);
            }
            else
            {
                allRoutines = routineHelper.getMostRecentRoutines();
            }

            List <Routine> routines = new List <Routine>();

            foreach (Routine r in allRoutines)
            {
                List <Job> jobs = helper.getAllJobsForRoutine(r.creatorUserName, r.assigneeUserName, r.routineTitle);
                if (jobs != null && jobs.Count() > 0)
                {
                    routines.Add(r);
                }
            }

            return(View(routines));
        }