示例#1
0
        public IActionResult Index()
        {
            string      str     = "";
            Random      r       = new Random();
            BlogDal     blogdal = new BlogDal();
            CategoryDal cadal   = new CategoryDal();

            List <Model.Category> list_ca = cadal.GetList("");

            for (int i = 0; i < 102; i++)
            {
                string         title  = $"新闻标题{i}";
                string         body   = title + "的内容";
                Model.Category ca     = list_ca[r.Next(0, list_ca.Count)];
                string         cabh   = ca.Num,
                               caname = ca.CaName;

                blogdal.Insert(new Model.Blog
                {
                    Title    = title,
                    Body     = body,
                    VisitNum = r.Next(100, 999),
                    CaNum    = cabh,
                    CaName   = caname,
                });
            }
            str = "添加102条测试新闻成功!";

            return(Content(str));
        }
示例#2
0
 public BlogController(IConfiguration config)
 {
     this.config       = config;
     _connectionString = config["ConnectionStrings:ConfigurationDatabase"];
     _blogDal          = new BlogDal(_connectionString);
 }
示例#3
0
 public BlogController(BlogDal bdal, CategoryDal cadal)
 {
     this.dal   = bdal;
     this.cadal = cadal;
 }
示例#4
0
 public GetAllBlogComments(IConfiguration config)
 {
     this.config       = config;
     _connectionString = config["ConnectionStrings:ConfigurationDatabase"];
     _blogDal          = new BlogDal(_connectionString);
 }
 public GetPostsForAdmin(IConfiguration config)
 {
     this.config       = config;
     _connectionString = config["ConnectionStrings:ConfigurationDatabase"];
     _blogDal          = new BlogDal(_connectionString);
 }
示例#6
0
 public HomeController(CategoryDal caDal, BlogDal bDal)
 {
     this.caDal = caDal;
     this.bDal  = bDal;
 }
 public RecomendedBlogs(IConfiguration config)
 {
     this.config       = config;
     _connectionString = config["ConnectionStrings:ConfigurationDatabase"];
     _blogDal          = new BlogDal(_connectionString);
 }