Exemple #1
0
 // Get all category names
 public static List<Category> GetAllCategoryNames()
 {
     int id;
     SqlConnection con1 = new SqlConnection(ConfigurationManager.ConnectionStrings["globaldb"].ConnectionString);
     string q1 = "select * from categories";
     SqlCommand com1 = new SqlCommand(q1, con1);
     SqlDataReader rdr;
     List<Category> list = new List<Category>();
     Category category;
     con1.Open();
     rdr = com1.ExecuteReader();
     while (rdr.Read())
     {
         category = new Category();
         category.categoryID = Convert.ToInt32(rdr[0]);
         category.categoryName = rdr[1].ToString();
         category.parentName = rdr[2].ToString();
         list.Add(category);
     }
     con1.Close();
     return list;
 }
Exemple #2
0
 public PostCategory(int _postid,Category _category)
 {
     postid = _postid;
     category = _category;
 }
Exemple #3
0
        //assign categories
        public static void Categories(int postid, List<string> lstCategories)
        {
            PostCategory.DeleteCatecoriesofPost(postid);

            foreach (string item in lstCategories)
            {

                    Category category = new Category();
                    category.GetCategoryId(item);
                    PostCategory postcategory = new PostCategory(postid, category);
                    postcategory.PostCategorySave();

            }
        }