Пример #1
0
        /// <summary>
        /// Christian Lopez
        /// 2017/04/14
        ///
        /// sees what tables the userId shows up in, and sets
        /// a bool[] in the order of customer, employee, supplier
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public bool[] GetUserRoles(int userId)
        {
            bool[]             roles = new bool[3];
            CommercialCustomer cust  = null;
            Employee           emp   = null;
            Supplier           supp  = null;

            try
            {
                cust = CustomerAccessor.RetrieveCommercialCustomerByUserId(userId);
                emp  = EmployeeAccessor.RetrieveEmployeeByUserId(userId);
                supp = SupplierAccessor.RetrieveSupplierByUserId(userId);
            }
            catch (Exception)
            {
                throw;
            }

            roles[0] = (cust != null && cust.IsApproved && cust.Active);
            roles[1] = (emp != null && (bool)emp.Active);
            roles[2] = (supp != null && supp.Active && supp.IsApproved);

            return(roles);
        }