public List <MixtapeDAL> MixtapeGenresGetAllMixtapesByGenreID(int skip, int take, int GenreID) { List <MixtapeDAL> ExpectedReturnValue = new List <MixtapeDAL>(); try { EnsureConnected(); using (SqlCommand command = new SqlCommand("MixtapeGenresGetAllMixtapesByGenreID", conn)) { command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.AddWithValue("@skip", skip); command.Parameters.AddWithValue("@take", take); command.Parameters.AddWithValue("@GenreID", GenreID); using (SqlDataReader reader = command.ExecuteReader()) { MixtapeMapper mm = new MixtapeMapper(reader); while (reader.Read()) { MixtapeDAL info = mm.ToMixtape(reader); ExpectedReturnValue.Add(info); } } } } catch (Exception ex) when(Log(ex)) { } return(ExpectedReturnValue); }
public MixtapeDAL MixtapeFindByID(int MixtapeID) { MixtapeDAL ExpectedReturnValue = null; try { EnsureConnected(); using (SqlCommand command = new SqlCommand("MixtapeFindByID", conn)) { command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.AddWithValue("@MixtapeID", MixtapeID); using (SqlDataReader reader = command.ExecuteReader()) { MixtapeMapper um = new MixtapeMapper(reader); int count = 0; while (reader.Read()) { ExpectedReturnValue = um.ToMixtape(reader); count++; } if (count > 1) { throw new Exception($"{count} Multiple users found for ID{MixtapeID}"); } } } } catch (Exception ex) when(Log(ex)) { } return(ExpectedReturnValue); }