Exemplo n.º 1
0
        public List <RoleDAL> RoleGetAll(int Skip, int Take)
        {        // retrieves all Roles
            List <RoleDAL> ReturnValue = new List <RoleDAL>();

            CheckConnection();
            try
            {
                using (SqlCommand command = new SqlCommand("RolesGetAll", _con))
                {
                    command.CommandType = System.Data.CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@skip", Skip);
                    command.Parameters.AddWithValue("@take", Take);
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        RoleMapper rm = new RoleMapper(reader);
                        while (reader.Read())
                        {
                            RoleDAL item = rm.ToRole(reader);
                            ReturnValue.Add(item);
                        }
                    }
                }
            }
            catch (Exception oops) when(Error.Log(oops))
            {
                //it's all done in the error.log
            }
            return(ReturnValue);
        }
Exemplo n.º 2
0
        public List <RoleDAL> GetRoles(int skip, int take)
        {
            List <RoleDAL> proposedReturnValue = new List <RoleDAL>();

            try
            {
                EnsureConnected();
                using (SqlCommand command = new SqlCommand("GetRoles", _connection))
                {
                    command.CommandType = System.Data.CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@Skip", skip);
                    command.Parameters.AddWithValue("@Take", take);
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        RoleMapper m = new RoleMapper(reader);
                        while (reader.Read())
                        {
                            RoleDAL r = m.RoleFromReader(reader);
                            proposedReturnValue.Add(r);
                        }
                    }
                }
            }
            catch (Exception ex) when(Log(ex))
            {
            }
            return(proposedReturnValue);
        }
Exemplo n.º 3
0
        // ----- Read ----- //
        public List <RoleDAL> Roles_Get(int skip, int take)
        {
            List <RoleDAL> proposedReturnValue = new List <RoleDAL>();

            try
            {
                EnsureConnected();
                using (SqlCommand command = new SqlCommand("Roles_Get", _connection))
                {
                    command.CommandType = System.Data.CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@Skip", skip);
                    command.Parameters.AddWithValue("@Take", take);
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        RoleMapper mapper = new RoleMapper(reader);
                        while (reader.Read())
                        {
                            RoleDAL reading = mapper.RoleFromReader(reader);
                            proposedReturnValue.Add(reading);
                        }
                    }
                }
            }
            catch (Exception ex) when(Log(ex))
            {
                // No access to scope - Exception thrown before entering
            }
            return(proposedReturnValue);
        }
Exemplo n.º 4
0
        public RoleDAL RoleFindByID(int RoleID)
        {        // retrieve a role by ID (we dont expect multiple records here)
            RoleDAL ReturnValue = null;

            CheckConnection();
            try
            {
                using (SqlCommand command = new SqlCommand("RoleFindByID", _con))
                {
                    command.CommandType = System.Data.CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@RoleID", RoleID);
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        RoleMapper rm    = new RoleMapper(reader);
                        int        count = 0;
                        while (reader.Read())
                        {
                            ReturnValue = rm.ToRole(reader);
                            count++;
                        }
                        if (count > 1)
                        {
                            throw new Exception($"{count} Multiple Roles found for ID {RoleID}");
                        }
                    }
                }
            }
            catch (Exception oops) when(Error.Log(oops))
            {
                //it's all done in the error.log
            }
            return(ReturnValue);
        }
        public RoleDAL RoleFindbyID(int RoleID)
        {
            RoleDAL proposedReturnValue = null;

            EnsureConnected();
            using (SqlCommand command = new SqlCommand("RoleFindByID", sec))
            {
                command.CommandType = System.Data.CommandType.StoredProcedure;
                command.Parameters.AddWithValue("RoleID", @RoleID);
                using (SqlDataReader reader = command.ExecuteReader())
                {
                    RoleMapper rm    = new RoleMapper(reader);
                    int        count = 0;
                    while (reader.Read())
                    {
                        proposedReturnValue = rm.ToRole(reader);
                        count++;
                    }
                    if (count > 1)
                    {
                        throw new Exception($"{ count } many roles were found for ID { RoleID}");
                    }
                }
            }
            return(proposedReturnValue);
        }
Exemplo n.º 6
0
        public RoleDAL Role_FindByRoleID(int roleID)
        {
            RoleDAL ProposedReturnValue = null;

            try
            {
                EnsureConnected();
                using (SqlCommand command = new SqlCommand("Role_FindByRoleID", _connection))
                {
                    command.CommandType = System.Data.CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@RoleID", roleID);
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        RoleMapper mapper = new RoleMapper(reader);
                        int        count  = 0;
                        while (reader.Read())
                        {
                            ProposedReturnValue = mapper.RoleFromReader(reader);
                            count++;
                        }
                        if (count > 1)
                        {
                            throw new Exception($"Found more than 1 Role with key {roleID}");
                        }
                    }
                }
            }
            catch (Exception ex) when(Log(ex))
            {
                // No access to scope - Exception thrown before entering
            }
            return(ProposedReturnValue);
        }
Exemplo n.º 7
0
        public RoleDAL RoleFindByID(int RoleID)
        {
            RoleDAL ExpectedReturnValue = null;

            try
            {
                EnsureConnected();
                using (SqlCommand command = new SqlCommand("RoleFindByID", conn))
                {
                    command.CommandType = System.Data.CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@RoleID", RoleID);
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        RoleMapper RM    = new RoleMapper(reader);
                        int        count = 0;
                        while (reader.Read())
                        {
                            ExpectedReturnValue = RM.ToRole(reader);
                            count++;
                        }
                        if (count > 1)
                        {
                            throw new Exception($"{count} Multiple Roles found for ID {RoleID}");
                        }
                    }
                }
            }
            catch (Exception ex) when(Log(ex))
            {
            }
            return(ExpectedReturnValue);
        }
Exemplo n.º 8
0
        public List <RoleDAL> RolesGetAll(int skip, int take)
        {
            List <RoleDAL> ExpectedReturnValue = new List <RoleDAL>();

            try
            {
                EnsureConnected();
                using (SqlCommand command = new SqlCommand("RolesGetAll", conn))
                {
                    command.CommandType = System.Data.CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@skip", skip);
                    command.Parameters.AddWithValue("@take", take);
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        RoleMapper RM = new RoleMapper(reader);

                        while (reader.Read())
                        {
                            RoleDAL info = RM.ToRole(reader);
                            ExpectedReturnValue.Add(info);
                        }
                    }
                }
            }
            catch (Exception ex) when(Log(ex))
            {
            }
            return(ExpectedReturnValue);
        }
Exemplo n.º 9
0
        public List <RoleDAL> GetRoles(int skip, int take)
        {
            List <RoleDAL> rv = new List <RoleDAL>();

            try
            {
                EnsureConnected();
                using (SqlCommand command = new SqlCommand("GetRoles", Con))
                {
                    command.CommandType = System.Data.CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@skip", skip);
                    command.Parameters.AddWithValue("@take", take);

                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        RoleMapper mapper = new RoleMapper(reader);
                        while (reader.Read())
                        {
                            RoleDAL c = mapper.ToRole(reader);
                            rv.Add(c);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log(ex);
                throw;
            }
            return(rv);
        }
Exemplo n.º 10
0
        public RoleDAL FindRoleByUserName(string UserName)
        {
            RoleDAL rv = null;

            try
            {
                EnsureConnected();
                using (SqlCommand command = new SqlCommand("FindRoleByUserName", Con))
                {
                    command.CommandType = System.Data.CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@UserName", UserName);

                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        RoleMapper mapper = new RoleMapper(reader);
                        if (reader.Read())
                        {
                            rv = mapper.ToRole(reader);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log(ex);
                throw;
            }
            return(rv);
        }
Exemplo n.º 11
0
        public List <RoleDAL> RolesGetAll(int Skip, int Take)
        {
            List <RoleDAL> proposedReturnValue = new List <RoleDAL>();

            try
            {
                EnsureConnected();
                using (SqlCommand command = new SqlCommand("RolesGetAll", _con))
                {
                    command.CommandType = System.Data.CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@skip", Skip);
                    command.Parameters.AddWithValue("@take", Take);
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        RoleMapper rm = new RoleMapper(reader);
                        while (reader.Read())
                        {
                            RoleDAL item = rm.ToRole(reader);
                            proposedReturnValue.Add(item);
                        }
                    }
                }
            }
            catch (Exception ex) when(Log(ex))
            {
                // stays empty
            }
            return(proposedReturnValue);
        }
Exemplo n.º 12
0
        public RoleDAL RoleFindByID(int RoleID)
        {
            RoleDAL proposedreturnValue = null;

            try
            {
                EnsureConnected();
                using (SqlCommand command = new SqlCommand("RoleFindByID", _con))
                {
                    command.CommandType = System.Data.CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@RoleID", RoleID);     //QuotesQuotesQuotes
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        RoleMapper rm    = new RoleMapper(reader);
                        int        count = 0;
                        while (reader.Read())
                        {
                            proposedreturnValue = rm.ToRole(reader);
                            count++;
                        }
                        if (count > 1)
                        {
                            throw new Exception($"Multiple Roles found for ID {RoleID}");
                        }
                    }
                }
            }
            catch (Exception ex) when(Log(ex))
            {
                // stays empty
            }
            return(proposedreturnValue);
        }
Exemplo n.º 13
0
        //ROLE
        public RoleDal FindRoleByID(int RoleID)
        {
            RoleDal ProposedReturnValue = null;

            try
            {
                EnsureConnected();
                using (SqlCommand command = new SqlCommand("FindRoleByID", _connection))
                {
                    command.CommandType = System.Data.CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@RoleID", RoleID);
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        RoleMapper m     = new RoleMapper(reader);
                        int        count = 0;
                        while (reader.Read())
                        {
                            ProposedReturnValue = m.RoleFromReader(reader);
                            count++;
                        }
                        if (count > 1)
                        {
                            throw new Exception($"Found more than 1 Role with key{ RoleID}");
                        }
                    }
                }
            }
            catch (Exception ex) when(Log(ex))
            {
            }
            return(ProposedReturnValue);
        }