コード例 #1
0
 public ActionResult EditPosts(Author au)
 {
     using (AuthorDAL service = new AuthorDAL())
     {
         try
         {
             service.Edit(au);
             TempData["Message"] = Helper.MsgBox.GetMsg("success", "Success! ", "Your data  has been updated");
         }
         catch (Exception ex)
         {
             TempData["Message"] = Helper.MsgBox.GetMsg("danger", "Error", ex.Message);
         }
     }
     return(RedirectToAction("Index"));
 }
コード例 #2
0
 [HttpPost, ActionName("EditAuthor")]              //blm bisa
 public ActionResult EditPost(int?id, Authors cat) //int? --> bisa diisi nilai NULL
 {
     if (id == null)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
     }
     using (AuthorDAL service = new AuthorDAL())
     {
         try
         {
             service.Edit(id.Value, cat);
             TempData["Message"] = Helper.MsgBox.GetMsg("success", "Success! ", "Your data has been updated");
         }
         catch (Exception ex)
         {
             TempData["Message"] = Helper.MsgBox.GetMsg("danger", "Error", ex.Message);
         }
     }
     return(RedirectToAction("Index"));
 }