public ActionResult ProjectsDropdown()
        {
            UserSettings userSettings = SessionWrapper.UserSettings;

            var vm = new ProjectsDropdownVM();
            var projects = from p in db.Projects
                           orderby p.Title
                           select p;
            vm.Values = new SelectList(projects.ToList(), "ProjectID", "Title");

            if (userSettings.workingProject > 0)
            {
                // Select the current project in user settings.
                vm.SelectedValue = userSettings.workingProject;
            }
            else
            {
                if (vm.Values.Any())
                {
                    // Set the current project using the first value. This will be changed in the future.
                    userSettings.workingProject = Int32.Parse(vm.Values.First().Value);
                }
                else
                {
                    // TODO: handle this case.
                    throw new Exception("No projects.");
                }
            }

            return PartialView("_ProjectsDropdown", vm);
        }
 public ActionResult SetCurrent(ProjectsDropdownVM vm)
 {
     setCurrentProjectID(vm.SelectedValue);
     return Redirect(Request.UrlReferrer.ToString());
 }