public ActionResult Start(string id)
        {
           
            if (string.IsNullOrWhiteSpace(id))
            {
                return RedirectToActionPermanent("Identify", new { CCApp = ViewBag.CCApp });
            }


            AppUser appUser = new AppUser(id);

            if (!appUser.IsValid)
            {
                return RedirectToAction("Identify");
            }

            if (appUser.AssignmentCount == 0 && appUser.IsManager)
            {
                return RedirectToAction("Dashboard", "Admin", new { employeeid = id });
            }

            ViewBag.EmployeeID = id;
            ViewBag.ReturnToHub = Resources.Literals.ReturnToControlCenter;

            return View(appUser);
        }
        public ActionResult Module()
        {
            AppUser appUser = new AppUser(ViewBag.EmployeeID);

            if (!appUser.IsValid)
            {
                return RedirectToAction("Identify");
            }

            ViewBag.ReturnToHub = Resources.Literals.ReturnToControlCenter;

            return View(appUser);
        }
        public ActionResult Identify(AppUser appUser)
        {

        
            if (appUser.IsValid)
            {
                if (appUser.IsManager || appUser.HasCurrentAssignments)
                {
                    return RedirectToAction("Start", new { id = appUser.EmployeeID, CCApp = ViewBag.CCApp, EmployeeID = appUser.EmployeeID });
                }
                else
                {
                    return RedirectToAction("NoneAvailable", new { id = appUser.EmployeeID, CCApp = ViewBag.CCApp, EmployeeID = appUser.EmployeeID });
                }
            }

            return View();
        }
        public ActionResult Identify()
        {

            if (ViewBag.EmployeeID != null)
            {
                AppUser appUser = new AppUser(ViewBag.EmployeeID);
                if (appUser.IsValid)
                {
                    return RedirectToAction("Start");
                }
            }
            else if (Request.QueryString["EmployeeID"] != null)
            {
                AppUser appUser = new AppUser(Request.QueryString["EmployeeID"]);
                if (appUser.IsValid)
                {
                    return RedirectToAction("Start");
                }
            }

            return View();
        }
 public ActionResult NoneAvailable(string id)
 {
     AppUser appUser = new AppUser(id);
     ViewBag.ReturnToHub = Resources.Literals.ReturnToControlCenter;
     return View(appUser);
 }
        public ActionResult ViewModules()
        {
            AppUser appUser = new AppUser(ViewBag.EmployeeID);

            ViewBag.ReturnToHub = Resources.Literals.ReturnToControlCenter;
            return RedirectToAction("Module", new { EmployeeID = ViewBag.EmployeeID, CCApp = ViewBag.CCApp });
        }
        public ActionResult StartModule()
        {
            AppUser appUser = new AppUser(ViewBag.EmployeeID);
            if (appUser.AssignmentCount != 1)
            {
                return RedirectToAction("Start", new { EmployeeID = ViewBag.EmployeeID, CCApp = ViewBag.CCApp });
            }

            string id = (appUser.CurrentAssignmentId ?? "").ToString();
            ViewBag.ReturnToHub = Resources.Literals.ReturnToControlCenter;
            return RedirectToAction("Welcome", "Test", new { id = id, EmployeeID = ViewBag.EmployeeID, CCApp = ViewBag.CCApp });
        }
        public ActionResult Resume()
        {
            AppUser appUser = new AppUser(ViewBag.EmployeeID);
            if (appUser.CurrentAssignment != null)
            {
                if (appUser.CurrentAssignment.CurrentStatus == null)
                {
                    return RedirectToAction("Welcome", "Test", new { id = (appUser.CurrentAssignmentId ?? "").ToString(), EmployeeID = ViewBag.EmployeeID, CCApp = ViewBag.CCApp });
                }
                else if (appUser.CurrentAssignment.CurrentStatus.Section == Domain.StatusType.Presenting)
                {
                    return RedirectToAction("View", "Test", new { id = (appUser.CurrentAssignmentId??"").ToString(), Step = appUser.CurrentAssignment.CurrentStatus.Sequence, EmployeeID = ViewBag.EmployeeID, CCApp = ViewBag.CCApp });
                }
                else if (appUser.CurrentAssignment.CurrentStatus.Section == Domain.StatusType.Testing)
                {
                    return RedirectToAction("Take", "Test", new { id = (appUser.CurrentAssignmentId ?? "").ToString(), Step = appUser.CurrentAssignment.CurrentStatus.Sequence, EmployeeID = ViewBag.EmployeeID, CCApp = ViewBag.CCApp });
                }
            }
            else if (appUser.AssignmentInProgressMostRecentlyDue.HasValue)
            {
                if (appUser.AssignmentInProgressMostRecentlyDue.Value.Value.CurrentStatus == null)
                {
                    return RedirectToAction("Welcome", "Test", new { id = (appUser.AssignmentInProgressMostRecentlyDue.Value.Key??"").ToString(), EmployeeID = ViewBag.EmployeeID, CCApp = ViewBag.CCApp });
                }
                else if (appUser.AssignmentInProgressMostRecentlyDue.Value.Value.CurrentStatus.Section == Domain.StatusType.Presenting)
                {
                    return RedirectToAction("View", "Test", new { id = (appUser.AssignmentInProgressMostRecentlyDue.Value.Key ?? "").ToString(), Step = appUser.AssignmentInProgressMostRecentlyDue.Value.Value.CurrentStatus.Sequence, EmployeeID = ViewBag.EmployeeID, CCApp = ViewBag.CCApp });
                }
                else if (appUser.AssignmentInProgressMostRecentlyDue.Value.Value.CurrentStatus.Section == Domain.StatusType.Testing)
                {
                    return RedirectToAction("Take", "Test", new { id = (appUser.AssignmentInProgressMostRecentlyDue.Value.Key ?? "").ToString(), Step = appUser.AssignmentInProgressMostRecentlyDue.Value.Value.CurrentStatus.Sequence, EmployeeID = ViewBag.EmployeeID, CCApp = ViewBag.CCApp });
                }
            }

            ViewBag.ReturnToHub = Resources.Literals.ReturnToControlCenter;
            return View("Start", appUser);
        }