Example #1
0
 public ActionResult Delete(int id, Inmueble i)
 {
     try
     {
         // TODO: Add delete logic here
         var f = rf.ObtenerTodosPorInmuebleId(id);
         foreach (var item in f)
         {
             string wwwPath      = environment.WebRootPath;
             string path         = Path.Combine(wwwPath, "Uploads");
             string urlRenovada  = item.Url.Replace("/Uploads\\", "");
             string pathCompleto = Path.Combine(path, urlRenovada);
             System.IO.File.Delete(pathCompleto);
             rf.Baja(item.Id);
         }
         ri.Baja(id);
         TempData["Mensaje"] = "EliminaciĆ³n realizada correctamente";
         return(RedirectToAction(nameof(Index)));
     }
     catch (Exception ex)
     {
         ViewBag.Error      = ex.Message;
         ViewBag.StackTrate = ex.StackTrace;
         return(View(i));
     }
 }
Example #2
0
 public ActionResult Delete(int id, Foto f)
 {
     try
     {
         f = rf.ObtenerPorId(id);
         int    InmId        = f.InmuebleId;
         string wwwPath      = environment.WebRootPath;
         string path         = Path.Combine(wwwPath, "Uploads");
         string urlRenovada  = f.Url.Replace("/Uploads\\", "");
         string pathCompleto = Path.Combine(path, urlRenovada);
         System.IO.File.Delete(pathCompleto);
         rf.Baja(id);
         TempData["Mensaje"] = "EliminaciĆ³n realizada correctamente";
         return(RedirectToAction("Fotos", "Inmuebles", new { id = InmId }));
     }
     catch (Exception ex)
     {
         ViewBag.Error      = ex.Message;
         ViewBag.StackTrate = ex.StackTrace;
         return(View(f));
     }
 }