示例#1
0
        // Get category details
        public static CategoryDetails GetCategoryDetails(string categoryId)
        {
            // get a configured DbCommand object
            DbCommand comm = GenericDataAccess.CreateCommand();

            // set the stored procedure name
            comm.CommandText = "CatalogGetCategoryDetails";
            // create a new parameter
            DbParameter param = comm.CreateParameter();

            param.ParameterName = "@CategoryID";
            param.Value         = categoryId;
            param.DbType        = DbType.Int32;
            comm.Parameters.Add(param);

            // execute the stored procedure
            DataTable table = GenericDataAccess.ExecuteSelectCommand(comm);
            // wrap retrieved data into a CategoryDetails object
            CategoryDetails details = new CategoryDetails();

            if (table.Rows.Count > 0)
            {
                details.DepartmentId = Int32.Parse(table.Rows[0]["DepartmentID"].ToString());
                details.Name         = table.Rows[0]["Name"].ToString();
                details.Description  = table.Rows[0]["Description"].ToString();
            }
            // return department details
            return(details);
        }
示例#2
0
        public static string ToCategory(string departmentId, string categoryId, string page)
        {
            // prepare department and category URL names
            DepartmentDetails d           = CatalogAccess.GetDepartmentDetails(departmentId);
            string            deptUrlName = PrepareUrlText(d.Name);
            CategoryDetails   c           = CatalogAccess.GetCategoryDetails(categoryId);
            string            catUrlName  = PrepareUrlText(c.Name);

            // build category URL
            if (page == "1")
            {
                return(BuildAbsolute(String.Format("{0}-d{1}/{2}-c{3}/", deptUrlName, departmentId, catUrlName, categoryId)));
            }
            else
            {
                return(BuildAbsolute(String.Format("{0}-d{1}/{2}-c{3}/Page-{4}/", deptUrlName, departmentId, catUrlName, categoryId, page)));
            }
        }