示例#1
0
 public ActionResult Edit(int id)
 {
     //check update rights for current controller
     if (asset.Update)
     {
         //chet update rights for selected record
         DC_Article hOld = DC_Article.GetDC_Article(id);
         if (hOld != null)
         {
             return(View(hOld));
         }
         else
         {
             return(RedirectToAction("Index"));
         }
     }
     else
     {
         return(RedirectToAction("NoAccessRights", "Error"));
     }
 }
示例#2
0
        public ActionResult Edit(DC_Article article)
        {
            if (asset.Create)
            {
                if (ModelState.IsValid)
                {
                    DC_Article aOld = DC_Article.GetDC_Article(article.ArticleId);
                    if (aOld != null)
                    {
                        if (String.IsNullOrEmpty(article.Title))
                        {
                            return(Json(new { success = false, error = "Please input Title" }));
                        }
                        if (String.IsNullOrEmpty(article.PostContent))
                        {
                            return(Json(new { success = false, error = "Please input PostContent" }));
                        }
                        article.UpdatedDate = DateTime.Now;
                        article.UpdatedBy   = currentUser.UserName;
                        article.Update();
                    }
                    else
                    {
                        return(Json(new { success = false, error = "Article is already existed" }));
                    }
                }
                else
                {
                    return(Json(new { success = false, error = "Please insert all fields required" }));
                }
            }
            else
            {
                return(RedirectToAction("NoAccessRights", "Error"));
            }

            return(Json(new { success = true }));
        }