private void LoadSelectLists(Role role = null)
        {
            var positionTypes = from PositionType p in Enum.GetValues(typeof(PositionType))
                                select new { ID = p, Name = p.ToString().Replace("_", " ") };
            var salaryTypes = from SalaryType s in Enum.GetValues(typeof(SalaryType))
                              select new { ID = s, Name = s.ToString().Replace("_", " ") };
            var statusTypes = from RoleStatus r in Enum.GetValues(typeof(RoleStatus))
                              select new { ID = r, Name = r.ToString().Replace("_", " ") };
            //var agencies = from a in db.Agencies
            //               orderby a.Name
            //               select new { AgencyID = a.ID, Name = a.Name };

            if (role != null)
            {
                //  NOTE: The key (for ViewData) must match the Property name
                ViewData["PositionType"] = new SelectList(positionTypes, "ID", "Name", role.PositionType);
                ViewData["SalaryType"] = new SelectList(salaryTypes, "ID", "Name", role.SalaryType);
                ViewData["Status"] = new SelectList(statusTypes, "ID", "Name", role.Status);
                //ViewData["AgencyID"] = new SelectList(agencies, "AgencyID", "Name", role.Agency);
            }
            else
            {
                ViewData["PositionType"] = new SelectList(positionTypes, "ID", "Name");
                ViewData["SalaryType"] = new SelectList(salaryTypes, "ID", "Name");
                ViewData["Status"] = new SelectList(statusTypes, "ID", "Name");
                //ViewData["AgencyID"] = new SelectList(agencies, "AgencyID", "Name");
            }
        }
        public ActionResult Index(string verb)
        {
            if ((verb ?? "").ToLower() == "new")
            {
                LoadSelectLists();

                Role newRole = new Role();

                return View("Create", newRole);
            }
            else
            {
                return View(db.Roles.Include("Agency").ToList());
            }
        }
        public virtual ActionResult Index(string verb)
        {
            if ((verb ?? "").ToLower() == "new")
            {
                LoadSelectLists();

                Role newRole = new Role();
                newRole.AppliedForOn = new DateTime(
                    DateTime.Now.Year,
                    DateTime.Now.Month,
                    DateTime.Now.Day,
                    DateTime.Now.Hour,
                    30 * (DateTime.Now.Minute / 30),
                    0);

                return View("Create", newRole);
            }
            else
            {
                var roles = db.Roles
                            .Include("Agency")
                            .Where(r => r.Status != RoleStatus.Closed)
                            .OrderByDescending(r => r.Status)
                            .ThenByDescending(r => r.AppliedForOn);

                return View(roles.ToList());
            }
        }
 private void LoadAgencyConsultants(Role application)
 {
     var consultants = from c in db.Consultants
                       where c.Agency.ID == application.AgencyID
                       orderby c.LastName, c.FirstName
                       select new { ConsultantID = c.ID, Name = c.FirstName + " " + c.LastName };
     if (application.Consultant != null)
     {
         ViewData["ConsultantID"] = new SelectList(consultants, "ConsultantID", "Name", application.ConsultantID);
     }
     else
     {
         ViewData["ConsultantID"] = new SelectList(consultants, "ConsultantID", "Name");
     }
 }