Exemplo n.º 1
0
 public ActionResult Create(Post post)
 {
     try
     {
         if (ModelState.IsValid)
         {
             _postService.Add(post);
             TempData["Messeage"] = ValidateMesseage.AddSuccessful;
             return RedirectToAction("Index");
         }
         return View(post);
     }
     catch
     {
         return View();
     }
 }
Exemplo n.º 2
0
 public ActionResult Edit(int id, Post post)
 {
     try
     {
         if (ModelState.IsValid)
         {
             _postService.Update(post);
             TempData["Messeage"] = ValidateMesseage.UpdateSuccessful;
             return RedirectToAction("Index");
         }
         return View(post);
     }
     catch(WebException ex)
     {
         TempData["Messeage"] = ex.Message;
         return RedirectToAction("Index");
     }
 }