Beispiel #1
0
        public static List <Look> GetPopularLooksOfWeek(string db, long uId, int offset = 1, int limit = 15)
        {
            List <Look> looks = new List <Look>();
            string      query = "EXEC [stp_SS_GetPopularLooksOfWeek] @userId=" + uId + ",@offset=" + offset + ",@limit=" + limit;

            SqlConnection myConnection = new SqlConnection(db);

            try
            {
                myConnection.Open();
                using (SqlDataAdapter adp = new SqlDataAdapter(query, myConnection))
                {
                    SqlCommand cmd = adp.SelectCommand;
                    cmd.CommandTimeout = 300000;
                    System.Data.SqlClient.SqlDataReader dr = cmd.ExecuteReader();

                    looks = Look.GetLooksFromSqlReader(dr);
                }
            }
            finally
            {
                myConnection.Close();
            }

            return(looks);
        }
Beispiel #2
0
        public static List <Look> GetTaggedLooks(string db, long uId, long tagId, int offset = 1, int limit = 20, bool isPopular = false)
        {
            List <Look> looks = new List <Look>();

            string query;

            if (isPopular)
            {
                query = "EXEC [stp_SS_GetTaggedPopularLooks] @tagId=" + tagId + ",@userId=" + uId + ",@offset=" + offset + ",@limit=" + limit;
            }
            else
            {
                query = "EXEC [stp_SS_GetTaggedLooks] @tagId=" + tagId + ",@userId=" + uId + ",@offset=" + offset + ",@limit=" + limit;
            }

            SqlConnection myConnection = new SqlConnection(db);

            try
            {
                myConnection.Open();
                using (SqlDataAdapter adp = new SqlDataAdapter(query, myConnection))
                {
                    SqlCommand cmd = adp.SelectCommand;
                    cmd.CommandTimeout = 300000;
                    System.Data.SqlClient.SqlDataReader dr = cmd.ExecuteReader();
                    int countLooks = 0;
                    while (dr.Read())
                    {
                        countLooks = int.Parse(dr["total"].ToString());
                    }
                    dr.NextResult();
                    looks = Look.GetLooksFromSqlReader(dr);
                }
            }
            finally
            {
                myConnection.Close();
            }

            if (looks.Count == 0)
            {
                looks = null;
            }

            return(looks);
        }
Beispiel #3
0
        public static List <Look> GetHomePageLooks(string db, long uId, int offset = 1, int limit = 10, bool isFilter = true)
        {
            List <Look> looks = new List <Look>();
            string      query;

            if (isFilter)
            {
                query = "EXEC [stp_SS_GetHomePageLooks] @userId=" + uId + ",@offset=" + offset + ",@limit=" + limit;
            }
            else
            {
                query = "EXEC [stp_SS_GetHomePageLooks_NoFilter] @userId=" + uId + ",@offset=" + offset + ",@limit=" + limit;
            }


            SqlConnection myConnection = new SqlConnection(db);

            try
            {
                myConnection.Open();
                using (SqlDataAdapter adp = new SqlDataAdapter(query, myConnection))
                {
                    SqlCommand cmd = adp.SelectCommand;
                    cmd.CommandTimeout = 300000;
                    System.Data.SqlClient.SqlDataReader dr = cmd.ExecuteReader();

                    looks = Look.GetLooksFromSqlReader(dr);
                }
            }
            finally
            {
                myConnection.Close();
            }

            return(looks);
        }