Last active
January 18, 2018 16:11
-
-
Save dacanizares/1a75ac8a12379cbbfab993308c44dbc6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class HomeController : Controller | |
{ | |
private ApplicationDbContext db = new ApplicationDbContext(); | |
public ActionResult Index() | |
{ | |
return View(); | |
} | |
public ActionResult MostrarTodos() | |
{ | |
var videojuegos = db.Videojuegos.ToList(); | |
return PartialView("_MostrarTodos", videojuegos); | |
} | |
public ActionResult MostrarVideojuego(int id) | |
{ | |
Videojuego videojuego = db.Videojuegos.Find(id); | |
if (videojuego == null) | |
{ | |
return HttpNotFound(); | |
} | |
return PartialView("_MostrarVideojuego", videojuego); | |
} | |
// No olvidar hacer el dispose del dbcontext | |
// para liberar recursos ;) | |
protected override void Dispose(bool disposing) | |
{ | |
if (disposing) | |
{ | |
db.Dispose(); | |
} | |
base.Dispose(disposing); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment