Example #1
0
        /// <summary>
        /// Gets all the photos for an NSpot
        /// </summary>
        public static List <Photo> GetNSpotPhotosByNSpotID(int NSpotID)
        {
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetStoredProcCommand("HG_GetNSpotPhotosByNSpotID");

            db.AddInParameter(dbCommand, "NSpotID", DbType.Int32, NSpotID);

            List <Photo> Photos = null;

            //execute the stored procedure
            using (IDataReader dr = db.ExecuteReader(dbCommand))
            {
                Photos = Photo.PopulatePhotoWithJoin(dr);
                dr.Close();
            }

            return(Photos);
        }
Example #2
0
        public static List <Photo> GetTop100Photos(TopPhotoType topPhotoType)
        {
            string OrderByClause = string.Empty;

            switch (topPhotoType)
            {
            case TopPhotoType.Featured:
                OrderByClause = "Featured";
                break;

            case TopPhotoType.Discussed:
                OrderByClause = "NumberOfComments";
                break;

            case TopPhotoType.Viewed:
                OrderByClause = "NumberOfViews";
                break;

            case TopPhotoType.Rated:
                OrderByClause = "TotalVoteScore";
                break;
            }

            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbcommand = db.GetStoredProcCommand("HG_GetTop100Photos");

            db.AddInParameter(dbcommand, "OrderByClause", DbType.String, OrderByClause);

            List <Photo> Photos = null;

            //execute the stored procedure
            using (IDataReader dr = db.ExecuteReader(dbcommand))
            {
                Photos = Photo.PopulatePhotoWithJoin(dr);
            }

            // Create the object array from the datareader
            return(Photos);
        }