/// <summary>
        /// Creator: Chase Schutle
        /// Created: 03/01/2020
        /// Approver: Jordan Lindo
        ///
        /// Helper method to refresh listboxes after any type of relateed to a user's ERoles update
        /// </summary>
        /// <remarks>
        /// Updater:
        /// Updated:
        /// Update:
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void refreshListBox()
        {
            try
            {
                var activeRole =
                    _petUniverseUserERolesManager.RetrievePetUniverseUserERolesByPetUniverseUser(_petUniverseUser
                                                                                                 .PUUserID);
                lbAssignedERoles.ItemsSource = activeRole;
                List <string> roles = new List <string>();
                foreach (var item in _eRoleManager.RetrieveERolesByActive())
                {
                    roles.Add(item.ERoleID.ToString());
                }

                foreach (string role in activeRole)
                {
                    roles.Remove(role);
                }

                lbUnassignedERoles.ItemsSource = roles;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n\n", ex.InnerException.Message);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creator: Chase Schulte
        /// Created: 4/26/2020
        /// Approver: Kaleb Bachert
        ///
        /// method to set the datagrid based on filters
        /// </summary>
        /// <remarks>
        /// Updater: NA
        /// Updated: NA
        /// Update: NA
        ///
        /// </remarks>
        private void setDataGrid()
        {
            List <ShiftUserVM> shiftVMs      = new List <ShiftUserVM>();
            List <string>      assignedRoles = _universeUserERolesManager.RetrievePetUniverseUserERolesByPetUniverseUser(_user.PUUserID).FindAll(pu => pu.Contains("Supervisor"));
            List <string>      departments   = new List <string>();

            foreach (var item in assignedRoles)
            {
                departments.Add(_eRoleManager.RetrieveAllERoles().Find(er => er.ERoleID == item).DepartmentID);
            }
            if (cboDate.SelectedItem == null || cboDate.SelectedItem == "All Dates")
            {
                foreach (var department in departments)
                {
                    shiftVMs.AddRange(_shiftManager.RetrieveShiftsByScheduleAndDepartmentID(Convert.ToInt32(cboDateRange.SelectedItem.ToString().Substring(0, 7)), department));
                }
            }
            else
            {
                foreach (var department in departments)
                {
                    shiftVMs.AddRange(_shiftManager.RetrieveShiftsByScheduleAndDepartmentIDWithDate(Convert.ToInt32(cboDateRange.SelectedItem.ToString().Substring(0, 7)), department, Convert.ToDateTime(cboDate.SelectedItem)));
                }
            }
            //Remove current user's records
            for (int i = 0; i < shiftVMs.Count; i++)
            {
                if (shiftVMs.ElementAt(i).EmployeeID == _user.PUUserID)
                {
                    shiftVMs.RemoveAt(i);
                }
            }
            dgSchedule.ItemsSource = shiftVMs;
        }