Ejemplo n.º 1
0
        public GenreDAL GenreFindByID(int GenreID)
        {
            GenreDAL ExpectedReturnValue = null;

            try
            {
                EnsureConnected();
                using (SqlCommand command = new SqlCommand("GenreFindByID", conn))
                {
                    command.CommandType = System.Data.CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@GenreID", GenreID);
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        GenreMapper um    = new GenreMapper(reader);
                        int         count = 0;
                        while (reader.Read())
                        {
                            ExpectedReturnValue = um.ToGenre(reader);
                            count++;
                        }
                        if (count > 1)
                        {
                            throw new Exception($"{count} Multiple users found for ID{GenreID}");
                        }
                    }
                }
            }
            catch (Exception ex) when(Log(ex))
            {
            }
            return(ExpectedReturnValue);
        }
Ejemplo n.º 2
0
        public List <GenreDAL> GenresGetAll(int skip, int take)
        {
            List <GenreDAL> ExpectedReturnValue = new List <GenreDAL>();

            try
            {
                EnsureConnected();
                using (SqlCommand command = new SqlCommand("GenresGetAll", conn))
                {
                    command.CommandType = System.Data.CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@skip", skip);
                    command.Parameters.AddWithValue("@take", take);
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        GenreMapper um = new GenreMapper(reader);
                        while (reader.Read())
                        {
                            GenreDAL info = um.ToGenre(reader);
                            ExpectedReturnValue.Add(info);
                        }
                    }
                }
            }
            catch (Exception ex) when(Log(ex))
            {
            }
            return(ExpectedReturnValue);
        }