public List <BusinessEmployeeAccess> SelectAllByBusinessId(string businessId)
        {
            List <BusinessEmployeeAccess> employees = new List <BusinessEmployeeAccess>();

            using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["MyDBConnection"].ConnectionString))
            {
                using (SqlDataAdapter sda = new SqlDataAdapter(
                           "SELECT [dbo].[BusinessEmployeeAccess].*, " +
                           "[dbo].[BusinessUser].[id] userId, " +
                           "[dbo].[BusinessUser].[name] userName, " +
                           "[dbo].[BusinessUser].[email] userEmail, " +
                           "[dbo].[BusinessUser].[phone] userPhone " +
                           "FROM [dbo].[BusinessEmployeeAccess] " +
                           "INNER JOIN [dbo].[BusinessUser] " +
                           "ON [dbo].[BusinessEmployeeAccess].[userId] = dbo.BusinessUser.id " +
                           "WHERE [businessId] = @BusinessId;", con))
                {
                    sda.SelectCommand.Parameters.AddWithValue("@BusinessId", businessId.Trim());
                    DataSet ds = new DataSet();
                    sda.Fill(ds);

                    int rec_cnt = ds.Tables[0].Rows.Count;
                    if (rec_cnt > 0)
                    {
                        foreach (DataRow row in ds.Tables[0].Rows)
                        {
                            string id       = row["id"].ToString();
                            string userId   = row["userId"].ToString();
                            string roleId   = row["roleId"].ToString();
                            bool   rApp     = Convert.ToBoolean(row["readAppointment"]);
                            bool   wApp     = Convert.ToBoolean(row["writeAppointment"]);
                            bool   rCC      = Convert.ToBoolean(row["readCustomerChat"]);
                            bool   wCC      = Convert.ToBoolean(row["writeCustomerChat"]);
                            bool   accepted = Convert.ToBoolean(row["accepted"]);

                            string eId    = row["userId"].ToString();
                            string eName  = row["userName"].ToString();
                            string eEmail = row["userEmail"].ToString();
                            string ePhone = row["userPhone"].ToString();
                            BusinessEmployeeAccess bea = new BusinessEmployeeAccess(id, userId, businessId, roleId, rApp, wApp, rCC, wCC, accepted, new BusinessUser(eName, eEmail, "bruhbruhbruh", ePhone));
                            employees.Add(bea);
                        }
                    }
                }
            }
            return(employees);
        }
        public List <BusinessEmployeeAccess> SelectAcceptedByUserId(string userId)
        {
            List <BusinessEmployeeAccess> employeeBeas = new List <BusinessEmployeeAccess>();

            try
            {
                using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["MyDBConnection"].ConnectionString))
                {
                    using (SqlDataAdapter sda = new SqlDataAdapter(
                               "SELECT * " +
                               "FROM BusinessEmployeeAccess " +
                               "WHERE [userId] = @UserId AND [accepted] = 1;", con))
                    {
                        sda.SelectCommand.Parameters.AddWithValue("@UserId", userId);
                        DataSet ds = new DataSet();
                        sda.Fill(ds);

                        int rec_cnt = ds.Tables[0].Rows.Count;
                        if (rec_cnt > 0)
                        {
                            foreach (DataRow row in ds.Tables[0].Rows)
                            {
                                string businessId = row["businessId"].ToString();
                                string id         = row["id"].ToString();
                                string roleId     = row["roleId"].ToString();
                                bool   rApp       = Convert.ToBoolean(row["readAppointment"]);
                                bool   wApp       = Convert.ToBoolean(row["writeAppointment"]);
                                bool   rCC        = Convert.ToBoolean(row["readCustomerChat"]);
                                bool   wCC        = Convert.ToBoolean(row["writeCustomerChat"]);
                                bool   accepted   = Convert.ToBoolean(row["accepted"]);

                                BusinessEmployeeAccess bea = new BusinessEmployeeAccess(new Business().SelectOne(businessId), id, roleId, rApp, wApp, rCC, wCC, accepted);
                                employeeBeas.Add(bea);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error in BusinessEmployeeAccess SelectAcceptedByUserId - " + ex.Message + " " + ex.ToString());
            }

            return(employeeBeas);
        }
        public BusinessEmployeeAccess SelectOne(string beaId)
        {
            BusinessEmployeeAccess bea;

            using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["MyDBConnection"].ConnectionString))
            {
                using (SqlDataAdapter sda = new SqlDataAdapter("SELECT * FROM [dbo].[BusinessEmployeeAccess] WHERE [id] = @BeaId;", con))
                {
                    sda.SelectCommand.Parameters.AddWithValue("@BeaId", beaId);
                    DataSet ds = new DataSet();
                    sda.Fill(ds);

                    int rec_cnt = ds.Tables[0].Rows.Count;
                    if (rec_cnt == 0)
                    {
                        bea = null;
                    }
                    else
                    {
                        DataRow row = ds.Tables[0].Rows[0];

                        string id                = row["id"].ToString();
                        string userId            = row["userId"].ToString();
                        string businessId        = row["businessId"].ToString();
                        string roleId            = row["roleId"].ToString();
                        bool   readAppointment   = Convert.ToBoolean(row["readAppointment"]);
                        bool   writeAppointment  = Convert.ToBoolean(row["writeAppointment"]);
                        bool   readCustomerChat  = Convert.ToBoolean(row["readCustomerChat"]);
                        bool   writeCustomerChat = Convert.ToBoolean(row["writeCustomerChat"]);
                        bool   accepted          = Convert.ToBoolean(row["accepted"]);
                        bea = new BusinessEmployeeAccess(id, userId, businessId, roleId, readAppointment, writeAppointment, readCustomerChat, writeCustomerChat, accepted);
                    }
                }
            }
            return(bea);
        }