コード例 #1
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);
        }
コード例 #2
0
ファイル: ContextDAL.cs プロジェクト: JustinDavisA/Simuu
        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);
        }
コード例 #3
0
ファイル: ContextDAL.cs プロジェクト: JustinDavisA/Simuu
        // ----- 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);
        }
コード例 #4
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);
        }