Esempio n. 1
0
        public IActionResult Update(string id, BlogPost bookIn)
        {
            var book = _blogPostService.Get(id);

            if (book == null)
            {
                return(NotFound());
            }

            _blogPostService.Update(id, bookIn);

            return(NoContent());
        }
        public IActionResult Update(BlogPostMD metaData)
        {
            var result = _service.Update(metaData);

            if (!result.Status)
            {
                result.Data.ReferenceTypeOptions = _service.GetOptions();
                ViewBag.ErrorMessage             = result.Message;
                ViewBag.BlogId = metaData.BlogId;

                return(View(metaData));
            }

            return(RedirectToAction("Index", "BlogPost", new { blogId = metaData.BlogId }));
        }
Esempio n. 3
0
        public ActionResult Edit(BlogPostInfo oldModel, FormCollection fc)
        {
            bool   error    = false;
            bool   isAdd    = oldModel.Id == 0;
            int    userId   = PlantEngContext.Current.UserId;
            string userName = PlantEngContext.Current.UserName;

            if (string.IsNullOrEmpty(oldModel.Title))
            {
                error = true;
                ModelState.AddModelError("TITLEEMPTY", "标题不能为空");
            }
            if (string.IsNullOrEmpty(oldModel.Content))
            {
                error = true;
                ModelState.AddModelError("CONTENTEMPTY", "内容不能为空");
            }
            //系统分类
            oldModel.SystemCategoryId = Utils.StrToInt(fc["ddlSystemCategory"], 0);
            if (oldModel.SystemCategoryId == 0)
            {
                error = true;
                ModelState.AddModelError("SYSTEMCATERROR", "请选择系统分类");
            }
            if (!error && ModelState.IsValid)
            {
                oldModel.UserId   = userId;
                oldModel.UserName = userName;

                //获得系统分类名称
                oldModel.SystemCategoryName = PlantEng.Services.Category.TechService.GetById(oldModel.SystemCategoryId).Name;


                BlogPostService.Update(oldModel);
                if (isAdd)
                {
                    ViewBag.Msg = "添加成功,继续[<a href=\"/accounts/edit\">添加</a>]或[<a href=\"/accounts/blog/\">返回</a>]";
                }
                else
                {
                    ViewBag.Msg = "更新成功,<a href=\"/accounts/blog/\">返回</a>";
                }
            }
            return(View(oldModel));
        }
Esempio n. 4
0
 public IHttpActionResult Update([FromBody] BlogPostViewModel post)
 {
     blogPostService.Update(post);
     return(Json(post.ID));
 }