Exemplo n.º 1
0
 public ActionResult Delete(int id, Inmueble entidad)
 {
     try
     {
         inmueble.Delete(id);
         TempData["Mensaje"] = "El Inmueble fué borrado";
         return(RedirectToAction(nameof(Index)));
     }
     catch (Exception ex)
     {
         ViewBag.Error      = ex.Message;
         ViewBag.StackTrate = ex.StackTrace;
         return(View(entidad));
     }
 }
 public ActionResult Delete(int id, Inmueble e)
 {
     try
     {
         repositorio.Delete(id);
         return(RedirectToAction(nameof(Index)));
     }
     catch (SqlException ex)
     {
         TempData["Error"] = ex.Number == 547 ? "No se puede borrar el Inmueble porque esta utilizado" : "Ocurrio un error.";
         return(RedirectToAction(nameof(Index)));
     }
     catch (Exception ex)
     {
         TempData["Error"] = "Ocurrio un error." + ex.ToString();
         return(RedirectToAction(nameof(Index)));
     }
 }