public List <FigureDAL> FiguresGetRelatedToCivID(int Skip, int Take, int CivID) { List <FigureDAL> proposedReturnValue = new List <FigureDAL>(); try { EnsureConnected(); using (SqlCommand command = new SqlCommand("FiguresGetRelatedToCivID", _con)) { command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.AddWithValue("@Skip", Skip); command.Parameters.AddWithValue("@Take", Take); command.Parameters.AddWithValue("@CivID", CivID); using (SqlDataReader reader = command.ExecuteReader()) { FigureMapper fm = new FigureMapper(reader); while (reader.Read()) { FigureDAL item = fm.ToFigure(reader); proposedReturnValue.Add(item); } } } } catch (Exception ex) when(Log(ex)) { // stays empty } return(proposedReturnValue); }
public FigureDAL FigureFindByID(int FigureID) { FigureDAL proposedReturnValue = null; try { EnsureConnected(); using (SqlCommand command = new SqlCommand("FigureFindByID", _con)) { command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.AddWithValue("@FigureID", FigureID); using (SqlDataReader reader = command.ExecuteReader()) { FigureMapper fm = new FigureMapper(reader); int count = 0; while (reader.Read()) { proposedReturnValue = fm.ToFigure(reader); count++; } if (count > 1) { throw new Exception($"Multiple Figures found for ID {FigureID}"); } } } } catch (Exception ex) when(Log(ex)) { // stays empty } return(proposedReturnValue); }