Example #1
0
 public ActionResult Delete(int id, FormCollection form)
 {
     try
     {
         if (ModelState.IsValid)
         {
             ServicesEstado objDB = new ServicesEstado();
             Estado dto = new Estado();
             dto.Id = id;
             if (objDB.Delete(dto))
                 return RedirectToAction("Index");
             else
             {
                 ViewData["Msg"] = "Erro ao excluir";
                 return View();
             }
         }
         else
         {
             ViewData["Msg"] = "Campos inválidos.";
             return View();
         }
     }
     catch (Exception ex)
     {
         Utils.Log.DoLog(ex, System.Diagnostics.EventLogEntryType.Error, "Delete", "EstadoController");
         ViewData["Msg"] = "Erro ao excluir";
         return View();
     }
 }
Example #2
0
 public JsonResult DeleteAjax(int id)
 {
     try
     {
         ServicesEstado objDB = new ServicesEstado();
         Estado dto = new Estado();
         dto.Id = id;
         if (objDB.Delete(dto))
             return Json(new { Result = "OK" });
         else
             return Json(new { Result = "ERROR", Message = "Erro ao excluir." });
     }
     catch (Exception ex)
     {
         return Json(new { Result = "ERROR", Message = ex.Message });
     }
 }