Example #1
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name=""></param>
        /// <returns></returns>
        public bool update(Model.Blog m)
        {
            // Dapper - Update
            using (var connection = ConnectionFactory.GetOpenConnection())
            {
                int res = connection.Execute(@"UPDATE [blog]
                                                   SET 
                                                 [title] = @title
                                                  ,[body] = @body
                                                  ,[body_md] = @body_md
                                                  ,[visitnum] = @visitnum
                                                  ,[cabh] = @cabh
                                                  ,[caname] = @caname
                                                  ,[remark] =@remark
                                                  ,[sort] = @sort
                                                    WHERE id=@id", m);

                if (res > 0)
                {
                    return(true);
                }

                return(false);
            }
        }
        public IActionResult Add(Model.Blog m)
        {
            m.CreateDate = DateTime.Now;
            if (m.CaName == null)
            {
                m.CaName = "默认";
            }
            Model.Category ca = cadal.GetModelByBh(m.CaBh);
            if (ca != null)
            {
                m.CaName = ca.CaName;
            }

            if (m.Id == 0)
            {
                //新增
                dal.Insert(m);
            }
            else
            {
                //修改
                dal.Update(m);
            }
            return(Redirect("/Adnn1n/Blog/Index"));
        }
Example #3
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {

                Model.Blog model = new Model.Blog
                {
                    Content = Server.HtmlEncode(this.pageblogedit.Value),
                    CreateDate = System.DateTime.Now,
                    ImgUrl = SaveUploadFile(),
                    IsCheck = false,
                    Title = this.txtTitle.Value,
                    ProjectId = int.Parse(pid)
                };
                IBlogService iBlogSec = GetBusinessInterface<IBlogService>();
                if (iBlogSec.Add(model))
                {
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>showDialog('Attion','create success','BlogDetails.aspx?bid=" + model .blogId+ "');</script>");
                }
            }
            catch (Exception exp)
            {
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>showDialog('Attion','create blg failed');</script>");
            }
        }
Example #4
0
 /// <summary>
 /// 新增
 /// </summary>
 /// <returns></returns>
 public int Insert(Model.Blog m)
 {
     using (var connection = ConnectionFactory.GetOpenConnection(ConnStr))
     {
         int resid = connection.Query <int>(
             @"INSERT INTO Blog
                ( Title
                ,CreateDate
                ,Body
                ,Body_md
                ,VisitNum
                ,CaBh
                ,CaName
                ,Remark
                ,Sort)
          VALUES
                ( @Title
                ,@CreateDate
                ,@Body
                ,@Body_md
                ,@VisitNum
                ,@CaBh
                ,@CaName
                ,@Remark
                ,@Sort);SELECT @@IDENTITY;",
             m).First();
         return(resid);
     }
 }
Example #5
0
 /// <summary>
 /// Insert
 /// </summary>
 /// <returns></returns>
 public int Insert(Model.Blog m)
 {
     using (var connection = ConnectionFactory.GetOpenConnection(ConnStr))
     {
         int resid = connection.Query <int>(
             @"INSERT INTO [dbo].[Blog]
                ( [Title]
                ,[Body]
                ,[Body_md]
                ,[VisitNum]
                ,[CaNum]
                ,[CaName]
                ,[Remark]
                ,[Sort])
          VALUES
                ( @Title
                ,@Body
                ,@Body_md
                ,@VisitNum
                ,@CaNum
                ,@CaName
                ,@Remark
                ,@Sort);SELECT @@IDENTITY;",
             m).First();
         return(resid);
     }
 }
Example #6
0
 public bool Update(Model.Blog model)
 {
     using (var connection = ConnectionFactory.GetOpenConnection(ConnStr))
     {
         int res = connection.Execute(
             @"UPDATE Blog SET [Title] = @Title,[Body] = @Body,[Body_md] = @Body_md,[VisitNo] = @VisitNo,[CateNo] = @CateNo,[CateName] = @CateName,[Remark] = @Remark,[Sort] = @Sort WHERE Id = @Id", model);
         return(res > 0);
     }
 }
Example #7
0
 /// <summary>
 /// 新增
 /// </summary>
 /// <param name="m"></param>
 /// <returns></returns>
 public int Insert(Model.Blog m)
 {
     using (var connection = ConnectionFactory.GetConnection()) {
         int resid = connection.Query <int>(
             @"INSERT INTO blog(title,body,body_md,visitnum,categorynum,categoryname,remark,sort) 
                     values(@Title,@Body,@Body_md,@VisitNum,@CategoryNum,@CategoryName,@remark,@Sort);SELECT @@IDENTITY;",
             m).FirstOrDefault();
         return(resid);
     }
 }
 public IActionResult Add(int?id)
 {
     ViewBag.calist = cadal.GetList("pbh='01'");
     Model.Blog m = new Model.Blog();
     if (id != null)
     {
         m = dal.GetModel(id.Value);
     }
     return(View(m));
 }
Example #9
0
 private static Model.Blog GetBlog(int id)
 {
     Model.Blog post = new Model.Blog
     {
         Id     = id,
         Author = "Author " + id.ToString(),
         Post   = "Lotsa Lorem Ipsum. " + id.ToString(),
         Title  = "Lorem Ipsum Title. " + id.ToString()
     };
     return(post);
 }
Example #10
0
        public Model.Blog GetFirstOrDefault(int id)
        {
            Model.Blog m   = null;
            string     sql = @"select * from blog where id=@id";

            using (var connection = ConnectionFactory.OpenConnection(ConnStr))
            {
                m = connection.QueryFirstOrDefault <Model.Blog>(sql, new { id = id });
            }
            return(m);
        }
Example #11
0
        public IActionResult Show(int id)
        {
            Model.Blog blog = blogdal.GetModel(id);
//            if (blog == null)
//            {
//                return Content("找不到该博客!");
//            }
            ViewBag.blogdal   = blogdal;
            ViewBag.calist    = catedal.GetList("");
            ViewBag.blogmonth = blogdal.GetBlogMonth();
            return(View(blog));
        }
Example #12
0
        public ActionResult Show(int id)
        {
            ViewBag.blogdal = dal;

            //  ViewBag.calist = cadal.GetIndexLeft_Ca();
            Model.Blog b = dal.GetModel(id);
            if (b == null)
            {
                return(Content("找不到该博客"));
            }
            return(View(b));
        }
Example #13
0
 /// <summary>
 /// 修改
 /// </summary>
 /// <param name="m"></param>
 /// <returns></returns>
 public bool Update(Model.Blog bo)
 {
     using (var connection = ConnectionFactory.GetOpenConnection(ConnStr))
     {
         int res = connection.Execute(@"UPDATE Blog SET Title=@Title,Body=@Body,Body_md=@Body_md,VisitNum=@VisitNum,CaBh=@CaBh,CaName=@CaName,Remark=@Remark,Sort=@Sort WHERE Id=@Id", bo);
         if (res > 0)
         {
             return(true);
         }
         return(false);
     }
 }
Example #14
0
        public bool Update(Model.Blog m)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update `blog` set ");
            strSql.Append("title=@title, body=@body, body_md=@body_md, visitnum=@visitnum, cabh=@cabh, caname=@caname, remark=@remark, sort=@sort, updatetime=@updatetime  ");
            strSql.Append(" where id=@id ");
            using (var connection = ConnectionFactory.OpenConnection(ConnStr))
            {
                int i = connection.Execute(strSql.ToString(), m);
                return(i > 0);
            }
        }
Example #15
0
        /// <summary>
        /// show blog
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public IActionResult Show(int id)
        {
            ViewBag.blogDal   = dal;
            ViewBag.calist    = cadal.GetList("");
            ViewBag.blogmonth = dal.GetBlogMonth();

            Model.Blog b = dal.GetModel(id);
            if (b == null)
            {
                return(Content("Not Found!"));
            }
            return(View(b));
        }
Example #16
0
 public IActionResult Show(int id)
 {
     Model.Blog m = dal.GetFirstOrDefault(id);
     if (m == null)
     {
         return(Content("扑街仔,某有这文章啊"));
     }
     ViewBag.calist    = cadal.GetIndexLeft_Ca();
     ViewBag.blogmonth = cadal.GetIndexLeft_Month();
     ViewBag.cadal     = cadal;
     ViewBag.blogdal   = dal;
     return(View(m));
 }
Example #17
0
 /// <summary>
 /// 新增编辑博客页面
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public IActionResult Add(int?id)
 {
     ViewBag.calist = catedal.GetList("ParentCate='0' ORDER BY CateName");
     Model.Blog b = new Model.Blog()
     {
         Id = 0,
     };
     if (id != null)
     {
         b = blogdal.GetModel(id.Value);
     }
     return(View(b));
 }
Example #18
0
        private void ShowInfo()
        {
            Model.Blog model = new Model.Blog();

            model = bll.GetModel(this.id, -1, -1, -1, 1, 1);

            if (null != model && model.BlogId > 0)
            {
                txtTitle.Text = model.Title;
                txtIntro.Value = model.Intro;
                txtContent.Value = model.Content;
                rdStatus.SelectedValue = model.BlogStatus.ToString();
                rdIsHot.SelectedValue = model.IsHot.ToString();
            }
        }
Example #19
0
        public int Insert(Model.Blog m)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into `blog`(");
            strSql.Append(" title, body, body_md, visitnum, cabh, caname, remark, sort, updatetime  )");
            strSql.Append(" values (");
            strSql.Append(" @title, @body, @body_md, @visitnum, @cabh, @caname, @remark, @sort, @updatetime  )");
            strSql.Append(";select @@IDENTITY");

            using (var connection = ConnectionFactory.OpenConnection(ConnStr))
            {
                int i = connection.QuerySingle <int>(strSql.ToString(), m);
                return(i);
            }
        }
Example #20
0
 protected void Page_Load(object sender, EventArgs e)
 {
     string bid = Request.QueryString["bid"];
     if (!string.IsNullOrEmpty(bid))
     {
         IBlogService iBlogSec = GetBusinessInterface<IBlogService>();
         model = iBlogSec.GetModel(int.Parse(bid));
         if (string.IsNullOrEmpty(model.ImgUrl))
         {
             this.imgblog.Visible = false;
         }
         else
         {
             this.imgblog.ImageUrl = base.ImgVirtualPath + model.ImgUrl;
         }
     }
 }
Example #21
0
 public IActionResult Add(Model.Blog m)
 {
     Model.Category ca = cadal.GetModelByBh(m.CaBh);
     if (ca != null)
     {
         m.CaName = ca.CaName;
     }
     if (m.Id == 0)
     {
         dal.Insert(m);
     }
     else
     {
         m.updatetime = DateTime.Now;
         dal.Update(m);
     }
     return(Redirect("/Admin/Blog/Index"));
 }
Example #22
0
 public IActionResult Add(Model.Blog m)
 {
     Model.Category ca = cadal.GetModelByNumber(m.CategoryNum);
     if (ca != null)
     {
         m.CategoryName = ca.CategoryName;
     }
     if (m.Id == 0)
     {
         //新增
         dal.Insert(m);
     }
     else
     {
         //修改
         dal.Update(m);
     }
     return(Redirect("/Admin/Blog/Index"));
 }
Example #23
0
 public IActionResult Add(Model.Blog m)
 {
     Model.Category ca = cadal.GetModelByBh(m.cabh);
     if (ca != null)
     {
         m.caname = ca.caname;
     }
     if (m.id == 0)
     {
         //新增
         dal.insert(m);
     }
     else
     {
         //修改
         dal.update(m);
     }
     return(Redirect("/Admin/Blog/Index"));
 }
Example #24
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="m"></param>
 /// <returns></returns>
 public bool Update(Model.Blog m)
 {
     using (var connection = new SqlConnection(ConnectionFactory.ConnectionString))
     {
         int res = connection.Execute(@"UPDATE [dbo].[Blog]
                                 SET [Title] = @Title
                                 ,[Body_md] = @Body_md
                                  ,[VistitNum] = @VistitNum
                                  ,[CaNumber] = @CaNumber
                                  ,[CaName] = @CaName
                                  ,[Remark] = @Remark
                                  ,[Sort] = @Sort
                                   WHERE Id=@Id", m);
         if (res > 0)
         {
             return(true);
         }
         return(false);
     }
 }
Example #25
0
 public IActionResult Show(int id)
 {
     Model.Blog b = dal.GetModel(id);
     if (b == null)
     {
         return(Content("找不到该博客!"));
     }
     else
     {
         Model.Blog blog = new Model.Blog {
             Id           = b.Id,
             CreateDate   = b.CreateDate,
             Title        = b.Title,
             Body         = b.Body,
             CategoryName = b.CategoryName,
             CategoryNum  = b.CategoryNum
         };
         return(View(blog));
     }
 }
Example #26
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="m"></param>
 public bool Update(Model.Blog m)
 {
     using (var connection = ConnectionFactory.GetConnection()) {
         int res = connection.Execute(@"UPDATE blog set 
                                                      title=@Title
                                                     ,body=@Body
                                                     ,body_md=@Body_md
                                                     ,visitnum=@VisitNum
                                                     ,categorynum=@CategoryNum
                                                     ,categoryname=@CategoryName
                                                     ,remark=@remark
                                                     ,sort=@Sort 
                                                     where id = @Id", m);
         if (res > 0)
         {
             return(true);
         }
         return(false);
     }
 }
Example #27
0
        public IActionResult Index()
        {
            string str = "";

            Random r = new Random();
            List <Model.Category> list = cadal.GetList("");

            for (int i = 0; i < 100; i++)
            {
                Model.Category ca = list[r.Next(0, list.Count)];
                Model.Blog     m  = new Model.Blog
                {
                    Title    = $"第{i}条数据",
                    Body     = $"第{i}条数据的内容",
                    CaBh     = ca.Bh,
                    CaName   = ca.CaName,
                    VisitNum = r.Next(100, 999)
                };

                bdal.Insert(m);
            }
            str = "添加100条数据成功";

            //str = "新增返回的值" + cadal.Insert(new Model.Category() {  CaName="789"}) + "<hr />";
            //bool b = cadal.Delete(7);
            //str += "删除ID=7的数据" + b + "<hr />";
            //Model.Category ca = cadal.GetModel(8);
            //if(ca!=null)
            //{
            //    ca.CaName = "新修改的名字" + DateTime.Now;
            //    bool b2 = cadal.Update(ca);
            //    str += "修改ID=8的实体类结果" + b2 + "<hr />";
            //}

            //List<Model.Category> list = cadal.GetList("");
            //foreach (var item in list)
            //{
            //    str += $"<div>分类ID:{item.Id},分类名称:{item.CaName}</div>";
            //}
            return(Content(str));
        }
Example #28
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string CreateBy = string.Empty;
            if (Utils.GetCookie(PTSKeys.ADMIN_NAME, PTSKeys.CDL_CMS_KEY) != null)
            {
                CreateBy = Utils.GetCookie(PTSKeys.ADMIN_NAME, PTSKeys.CDL_CMS_KEY);
            }

            int _RowEffects = 0;

            Model.Blog model = new Model.Blog();

            if (id > 0)
            {
                model = bll.GetModel(this.id, -1, -1, -1, 1, 1);
            }

            model.Title = txtTitle.Text.Trim();
            model.TitleUrl = Utils.GenURL(txtTitle.Text.Trim());
            model.Image = "";

            model.Intro = txtIntro.Value;
            model.Content = txtContent.Value;
            model.BlogStatus = Convert.ToInt32(rdStatus.SelectedValue);
            model.IsHot = Convert.ToInt32(rdIsHot.SelectedValue);
            model.CreateBy = CreateBy;

            bll.Update(model, ref _RowEffects);

            if (_RowEffects > 0)
            {

                JscriptMsg("Cập nhật thành công !", "List.aspx", "Success");
            }
            else
            {
                JscriptMsg("Lỗi xảy ra, vui lòng thử lại !", "", "Error");
            }
        }
Example #29
0
        public ActionResult <BlogCreationViewModel> Post([FromBody] UpdateBlogViewModel model)
        {
            var creationTime = ((DateTimeOffset)DateTime.UtcNow).ToUnixTimeSeconds();

            var blog = new Model.Blog
            {
                Title        = model.Title,
                Content      = model.Content,
                CreationTime = creationTime,
                LastEditTime = creationTime,
                OwnerId      = NVLInt64(HttpContext.User.Identity.Name, 0),
                Draft        = true
            };

            _blogRepository.Add(blog);
            _blogRepository.Commit();

            return(new BlogCreationViewModel
            {
                BlogId = blog.Id
            });
        }
Example #30
0
        public IActionResult Add(Model.Blog m)
        {
            Model.Category ca = cadal.GetModelByBh(m.cabh);
            if (ca != null)
            {
                m.caname = ca.CaName;
            }

            if (m.id == 0)
            {
                //新增
                m.createdate = DateTime.Now;
                dal.Add(m);
            }
            else
            {
                //修改
                m.updatetime = DateTime.Now;
                dal.Update(m);
            }
            return(Redirect("/Adnn1n/Blog/Index"));
        }
Example #31
0
 public IActionResult Add(Model.Blog blog)
 {
     blog.CreateDate = DateTime.Now;
     if (blog.CateNo == "0")
     {
         //新分类,先增加
         string cateNo = catedal.GetCateNo("0", 2);
         catedal.Insert(new Model.Category()
         {
             CateName = blog.CateName, CateNo = cateNo, CreateDate = DateTime.Now, ParentCate = "0", Remark = ""
         });
         blog.CateNo = cateNo;
     }
     if (blog.Id == 0)
     {
         blogdal.Insert(blog);
         return(Json(new { status = "y", info = "博客新增成功!" }));
     }
     else
     {
         blogdal.Update(blog);
         return(Json(new { status = "y", info = "博客编辑成功!" }));
     }
 }
Example #32
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int id = Request.QueryString["id"] != null?int.Parse(Request.QueryString["id"]) : -1;

            if (id < 0)
            {
                IList <string> segments = Request.GetFriendlyUrlSegments();
                if (segments.Count > 0)
                {
                    int.TryParse(segments[0], out id);
                }
            }
            if (id > 0)
            {
                Model.Blog post = GetBlog(id);

                if (post != null)
                {
                    title.Text       = post.Title;
                    postDetails.Text = post.Post;
                    author.Text      = post.Author;
                }
            }
        }
 public BlogViewModel(Model.Blog model)
 {
     ViewData = model;
 }
Example #34
0
        public List<Model.Blog> GetList(Int64 _BlogId, Int64 _MemberId, int _BlogStatus, int _IsHot, int _Start, int _Limit)
        {
            List<Model.Blog> lModel = new List<Model.Blog>();

            try
            {

                SqlParameter[] p =  {
                                        new SqlParameter("@BlogId", SqlDbType.Int, 4),
                                        new SqlParameter("@MemberId", SqlDbType.Int, 4),
                                        new SqlParameter("@BlogStatus", SqlDbType.Int, 4),
                                        new SqlParameter("@IsHot", SqlDbType.Int, 4),
                                        new SqlParameter("@Start", SqlDbType.Int, 4),
                                        new SqlParameter("@Limit", SqlDbType.Int, 4)
                                    };

                p[0].Value = _BlogId;
                p[1].Value = _MemberId;
                p[2].Value = _BlogStatus;
                p[3].Value = _IsHot;
                p[4].Value = _Start;
                p[5].Value = _Limit;

                DataTable dt = db.ExcuteSelectReturnDataTable("Blog_Select", CommandType.StoredProcedure, p);

                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        Model.Blog model = new Model.Blog();

                        model.Ind = Convert.ToInt32(dr["Ind"]);
                        model.BlogId = Convert.ToInt32(dr["BlogId"]);
                        model.MemberId = Convert.ToInt32(dr["MemberId"]);
                        model.FullName = dr["FullName"].ToString();
                        model.Email = dr["Email"].ToString();
                        model.Avatar = dr["Avatar"].ToString();
                        model.Title = dr["Title"].ToString();

                        model.TitleUrl = dr["TitleUrl"].ToString();
                        model.Image = dr["Image"].ToString();
                        model.Intro = dr["Intro"].ToString();
                        model.Content = dr["Content"].ToString();
                        model.BlogStatus = Convert.ToInt32(dr["BlogStatus"]);
                        model.BlogStatusText = dr["BlogStatusText"].ToString();
                        model.IsHot = Convert.ToInt16(dr["Ishot"]);
                        model.CreateBy = dr["CreateBy"].ToString();
                        model.CreateTime = dr["CreateTime"].ToString();
                        model.UpdateBy = dr["UpdateBy"].ToString();
                        model.UpdateTime = dr["UpdateTime"].ToString();
                        model.TotalRow = Convert.ToInt32(dr["TotalRow"]);

                        lModel.Add(model);
                    }

                }

            }
            catch (Exception ex)
            {
                PTSLog.Error(ex.Message);
            }

            return lModel;
        }
Example #35
0
 public static String InsertBLog(string _BlogNaslov, string _BlogSodrzina, int _blogGtupaID)
 {
     string _ret="0";
     MembershipUser myObject = Membership.GetUser();
     Guid UserID = (Guid)myObject.ProviderUserKey;
     Model.BazaEntities db = new Model.BazaEntities();
     try
     {
         Model.Blog newBlog = new Model.Blog();
         newBlog.BlogNaslov = _BlogNaslov;
         newBlog.BlogSodrzina = _BlogSodrzina;
         newBlog.BlogGrupaID = _blogGtupaID;
         newBlog.BlogBrojGlasovi = 0;
         newBlog.BlogBrojKomentar  = 0;
         newBlog.BlogBrojPregledi = 0;
         newBlog.BlogVreme  = DateTime.Now;
         newBlog.UserID  = UserID;
         db.AddToBlogs(newBlog);
         db.SaveChanges();
     }
     catch (Exception e)
     {
         _ret = e.Message;
     }
     return _ret;
 }