Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
 public MixtapeBLL(DataAccessLayer.MixtapeDAL Mixtape)
 {
     MixtapeID     = Mixtape.MixtapeID;
     MixtapePath   = Mixtape.MixtapePath;
     ArtistName    = Mixtape.ArtistName;
     Title         = Mixtape.Title;
     NumberOfSongs = Mixtape.NumberOfSongs;
     Length        = Mixtape.Length;
 }
        public MixtapeDAL ToMixtape(SqlDataReader reader)
        {
            MixtapeDAL ExpectedReturnValue = new MixtapeDAL();

            ExpectedReturnValue.MixtapeID     = reader.GetInt32(OffsetToMixtapeID);
            ExpectedReturnValue.MixtapePath   = reader.GetString(OffsetToMixtapePath);
            ExpectedReturnValue.ArtistName    = reader.GetString(OffsetToArtistName);
            ExpectedReturnValue.Title         = reader.GetString(OffsetToTitle);
            ExpectedReturnValue.NumberOfSongs = reader.GetInt32(OffsetToNumberOfSongs);
            ExpectedReturnValue.Length        = reader.GetInt32(OffsetToLength);
            return(ExpectedReturnValue);
        }