Пример #1
0
        public ActionResult DeleteFSHistory(int id)
        {
            var model = FSHistorySer.QueryWhere(c => c.id == id).FirstOrDefault();

            FSHistorySer.Delete(model, false);
            var result = FSHistorySer.SaveChanges();

            if (result > 0)
            {
                return(WriteSuccess("删除成功"));
            }
            return(WriteError("删除失败"));
        }
Пример #2
0
        /// <summary>
        /// 给前台页面浏览次数
        /// </summary>
        /// <returns></returns>
        public ActionResult UpdateLook(int id)
        {
            if (id <= 0)
            {
                return(WriteError("数据错误"));
            }
            var       model    = FSHistorySer.QueryWhere(c => c.id == id).FirstOrDefault();
            FSHistory newModel = new FSHistory();

            newModel.id   = id;
            newModel.Look = model.Look + 1;
            FSHistorySer.Edit(newModel, new string[] { "Look" });
            var result = FSHistorySer.SaveChanges();

            return(WriteSuccess("浏览成功"));
        }
Пример #3
0
        public ActionResult AddZan(int count, int id)
        {
            if (id < 0)
            {
                return(WriteError("网络错误"));
            }
            model.FSHistory model = new crm16.model.FSHistory();
            model.id    = id;
            model.Likes = ++count;

            FSHistorySer.Edit(model, new string[] { "Likes" });
            var result = FSHistorySer.SaveChanges();

            if (result > 0)
            {
                return(WriteSuccess("", count));
            }
            return(WriteError("网络错误"));
        }
Пример #4
0
        /// <summary>
        /// 给前台页面浏览次数
        /// </summary>
        /// <returns></returns>
        public ActionResult UpdateDisplay(int id, int val)
        {
            if (id <= 0)
            {
                return(WriteError("数据错误"));
            }
            FSHistory newModel = new FSHistory();

            newModel.id      = id;
            newModel.Display = val;
            FSHistorySer.Edit(newModel, new string[] { "Display" });
            var result = FSHistorySer.SaveChanges();

            if (result > 0)
            {
                return(WriteSuccess("设置成功"));
            }
            return(WriteError("设置失败"));
        }
Пример #5
0
        [ValidateInput(false)]//防止对文本验证,保存不了HTML元素
        public ActionResult UpdateFsHistory(string title, string Content, int id)
        {
            if (string.IsNullOrWhiteSpace(title))
            {
                return(WriteError("标题不能为空"));
            }
            if (string.IsNullOrWhiteSpace(Content))
            {
                return(WriteError("内容不能为空"));
            }
            FSHistory model = new FSHistory();

            model.Title    = title;
            model.Contents = Content;
            model.Image    = GetImageUrl(Content);
            if (id > 0)//是不是编辑
            {
                model.id = id;
                FSHistorySer.Edit(model, new string[] { "Title", "Contents", "Image" });
            }
            else
            {
                model.Likes       = 150; //默认有150个点赞
                model.Look        = 200; //默认有250浏览次数
                model.Creater     = "丰顺商会";
                model.Type        = 1;
                model.CreaterTime = model.UpdateTime = DateTime.Now;
                FSHistorySer.Add(model);
            }
            var result = FSHistorySer.SaveChanges();

            if (result > 0)
            {
                return(WriteSuccess("操作成功!"));
            }
            return(WriteError("操作失败"));
        }