public AdminVM() { BlogPosts = new List<BlogPost>(); Users = new List<ApplicationUser>(); Pages = new List<StaticPage>(); RolesList = new List<SelectListItem>(); Roles = new List<IdentityRole>(); User = new ApplicationUser(); Role = new IdentityRole(); BlogStats = new BlogStats(); }
public Response() { Users = new List <ApplicationUser>(); IdUserRoles = new List <IdentityUserRole>(); IdRoles = new List <IdentityRole>(); Hashtag = new Hashtag(); Hashtags = new List <Hashtag>(); BlogPost = new BlogPost(); BlogPosts = new List <BlogPost>(); StaticPage = new StaticPage(); StaticPages = new List <StaticPage>(); Category = new Category(); Categories = new List <Category>(); User = new ApplicationUser(); BlogStats = new BlogStats(); }
public Response() { Users = new List<ApplicationUser>(); IdUserRoles = new List<IdentityUserRole>(); IdRoles = new List<IdentityRole>(); Hashtag = new Hashtag(); Hashtags = new List<Hashtag>(); BlogPost = new BlogPost(); BlogPosts = new List<BlogPost>(); StaticPage = new StaticPage(); StaticPages = new List<StaticPage>(); Category = new Category(); Categories = new List<Category>(); User = new ApplicationUser(); BlogStats = new BlogStats(); }
public BlogStats GetBlogStats() { BlogStats blogStats = new BlogStats(); using (SqlConnection cn = new SqlConnection(Settings.ConnectionString)) { SqlCommand cmd = new SqlCommand(); //Total Users cmd.CommandText = "select count(AspNetUsers.Id) from AspNetUsers"; cmd.Connection = cn; cn.Open(); blogStats.TotalUsers = int.Parse(cmd.ExecuteScalar().ToString()); //Total Admins cmd.CommandText = "select count(AspNetUserRoles.RoleId) from AspNetUserRoles where RoleId = 1"; blogStats.TotalAdmins = int.Parse(cmd.ExecuteScalar().ToString()); //Total Posts cmd.CommandText = "select count(BlogPosts.BlogPostID) from BlogPosts"; blogStats.TotalPosts = int.Parse(cmd.ExecuteScalar().ToString()); //Total Active Posts cmd.CommandText = "select count(BlogPosts.BlogPostID) from BlogPosts where [Status] = 1"; blogStats.TotalActivePosts = int.Parse(cmd.ExecuteScalar().ToString()); //Total Hashtags cmd.CommandText = "select count(BlogPostHashtags.HashTagID) from BlogPostHashtags"; blogStats.TotalHashtags = int.Parse(cmd.ExecuteScalar().ToString()); //Total Static Pages cmd.CommandText = "select count(StaticPages.StaticPageID) from StaticPages where [Status] = 1"; blogStats.TotalStaticPages = int.Parse(cmd.ExecuteScalar().ToString()); //Hashtag Stats cmd.CommandText = "select ht.HashtagID, ht.HashtagTitle, count(bp.HashtagID) As NumHts from BlogPostHashtags bp " + "inner join Hashtags ht on bp.HashtagID = ht.HashtagID group by bp.HashtagID, ht.HashtagID, ht.HashtagTitle Order By NumHts Desc"; using (SqlDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { blogStats.Hashtags.Add(PopulateHashtagsFromReader(dr)); } } } return blogStats; }
public HomeVM() { BlogPosts = new List<BlogPost>(); BlogStats = new BlogStats(); Categories = new List<Category>(); }