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 Videojuego | |
{ | |
public int Id { get; set; } | |
public string Nombre { get; set; } | |
public string Descripcion { get; set; } | |
public string ImagenUrl { get; set; } | |
} |
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() |
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
@model IEnumerable<ProjectDemo.Models.Videojuego> | |
@foreach (var item in Model) { | |
} |
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
@model IEnumerable<ProjectDemo.Models.Videojuego> | |
<div class="list-group"> | |
@foreach (var item in Model) | |
{ | |
<a data-url="@Url.Content(string.Format("~/Home/MostrarVideojuego/{0}", item.Id))" | |
class="list-group-item"> | |
@item.Nombre | |
</a> | |
} |
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
@model ProjectDemo.Models.Videojuego | |
<div class="panel panel-default"> | |
<div class="panel-heading"> | |
<h3 class="panel-title"> | |
@Model.Nombre | |
</h3> | |
</div> | |
<div class="panel-body"> | |
<h4>Imagen</h4> |
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
private ApplicationDbContext db = new ApplicationDbContext(); |
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
<h2> | |
Videojuegos | |
</h2> | |
<div class="row"> | |
<div class="col-sm-4" id="todos"> | |
</div> | |
<div class="col-sm-8" id="videojuego"> |
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
@section scripts | |
{ | |
<script> | |
// Esta función se ejecuta al cargar la página | |
$(function () { | |
// Obtiene mediante ajax la partial view | |
// que tiene el listado de juegos | |
$.ajax({ | |
url: "@Url.Content("~/Home/MostrarTodos")" | |
}).done(function (data) { |
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
@section scripts | |
{ | |
<script> | |
// Aquí arriba debe ir lo que acabamos de programar | |
// Handler para el click en los elementos del div | |
// que contiene el listado de los videojuegos | |
$('#todos').on('click', 'a[data-url]', function () { | |
// Obtenemos la url a la que | |
// se debe hacer el llamado con ajax |
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
@{ | |
ViewBag.Title = "Bienvenido"; | |
} | |
<h2> | |
Videojuegos | |
</h2> | |
<div class="row"> | |
<div class="col-sm-4" id="todos"> |
OlderNewer