Ejemplo n.º 1
0
        // GET: Load
        public ActionResult Index()
        {
            var Loadboard = new LoadboardViewModel();

            Loadboard.StatusSelector = SelectListHelper.Generic(LoadBusiness.GetLoadStatuses(_user));

            //retrieve save searches
            Loadboard.SavedSearches = _user.SavedSearches.Where(i => i.Category == Globals.SearchCategories.Loadboard).ToList();

            //retrieve save loadboard settings
            var LoadboardSettings = _user.Settings.FirstOrDefault(i => i.SettingName == "Loadboard");

            if (LoadboardSettings != null)
            {
                Loadboard.Settings = LoadboardSettings.SettingValue;
            }


            using (var OfficeBusiness = new OfficeBusiness(_applicationServicesSetup, _user))
            {
                Loadboard.OfficeGroups = OfficeBusiness.GetUserGroupsByOffice(_user.OfficeId, new[] { Globals.Related.OfficeGroup.Members });

                //if just an agent, only show the groups you are apart of.
                if (_user.IsAgent() && !_user.IsEmployee())
                {
                    Loadboard.OfficeGroups = Loadboard.OfficeGroups.Where(i => i.Members.Select(u => u.Id == _user.Id).Any()).ToList();
                }
            }

            return(View(Loadboard));
        }
Ejemplo n.º 2
0
        private void SetSelectors()
        {
            using (OfficeBusiness officeBusiness = new OfficeBusiness(_applicationServicesSetup, _user))
            {
                if (_user.IsAdmin())
                {
                    ViewBag.OfficeSelector = Helpers.SelectListHelper.Offices(officeBusiness.ActiveOffices(), "-- Select an Office --");
                }


                else if (_user.IsManager() || _user.IsEmployee())
                {
                    ViewBag.GroupsSelector = Helpers.SelectListHelper.Groups(officeBusiness.GetUserGroupsByOffice(_user.OfficeId), "-- Select a Group --");
                }
            }

            using (UserBusiness userBusiness = new UserBusiness(_applicationServicesSetup, _user))
            {
                ViewBag.UserSelector = Helpers.SelectListHelper.Users(userBusiness.GetAllUsers(), "-- Select a User --");
            }
        }