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); }
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); }
// ----- 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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
//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); }