/// <summary>
        /// Christian Lopez
        /// Created on 2017/02/15
        ///
        /// Retrieves a Supplier by the user id
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public Supplier RetrieveSupplierByUserId(int userId)
        {
            Supplier s = null;

            try
            {
                s = SupplierAccessor.RetrieveSupplierByUserId(userId);
            }
            catch (SqlException ex)
            {
                throw new ApplicationException("There was a database error.", ex);
            }
            catch (Exception ex)
            {
                throw new ApplicationException("There was an unknown error.", ex);
            }

            if (null == s)
            {
                throw new ApplicationException("Could not find supplier for that user ID.");
            }

            return(s);
        }
Example #2
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);
        }