This file contains hidden or 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
// PeopleController | |
[HttpPost] | |
public async Task<int> Post(Person person) | |
{ | |
context.Add(person); | |
await context.SaveChangesAsync(); | |
return person.Id; | |
} | |
// create.razor |
This file contains hidden or 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
@page "/" |
This file contains hidden or 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
@page "/" | |
<h1>Piedra, Papel y Tijera</h1> | |
<button class="btn btn-info">Reiniciar</button> | |
<div class="opciones-oponente"> | |
<img src="papel.jpg" class="imagen" /> | |
</div> |
This file contains hidden or 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
.opciones-oponente { | |
display: flex; | |
justify-content: center; | |
margin-bottom: 20px; | |
} | |
.opciones-jugador { | |
display: flex; | |
justify-content: space-around | |
} |
This file contains hidden or 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
@page "/" | |
@using System.Timers |
This file contains hidden or 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
@code{ | |
Timer timer; | |
protected override void OnInitialized() | |
{ | |
timer = new Timer(); | |
timer.Interval = 500; // cada medio segundo | |
timer.Elapsed += TimerOnElapsed; // ejecutar este método | |
timer.Start(); | |
} |
This file contains hidden or 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
@code{ | |
... | |
public void Dispose() | |
{ | |
if (timer != null) | |
{ | |
timer.Dispose(); | |
} | |
} | |
} |
This file contains hidden or 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
@code{ | |
... | |
enum OpcionPPT | |
{ | |
Piedra, Papel, Tijera | |
} | |
enum EstatusJuego | |
{ | |
Victoria, Derrota, Empate |
This file contains hidden or 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
@code{ | |
... | |
class Jugada | |
{ | |
public OpcionPPT OptionPPT { get; set; } | |
public OpcionPPT VenceA { get; set; } | |
public OpcionPPT PierdeContra { get; set; } | |
public string Imagen { get; set; } | |
public EstatusJuego JugarContra(Jugada jugada2) |
This file contains hidden or 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
@code{ | |
List<Jugada> jugadas = new List<Jugada>() | |
{ | |
new Jugada{Imagen = "piedra.jpg", OptionPPT = OpcionPPT.Piedra, | |
VenceA = OpcionPPT.Tijera, PierdeContra = OpcionPPT.Papel}, | |
new Jugada{Imagen = "tijeras.jpg", OptionPPT = OpcionPPT.Tijera, | |
VenceA = OpcionPPT.Papel, PierdeContra = OpcionPPT.Piedra}, | |
new Jugada{Imagen = "papel.jpg", OptionPPT = OpcionPPT.Papel, |