feat : Component CardViewQuestion and BackButton
continuous-integration/drone/push Build is passing Details

Multiplayer_Php
Yvan CALATAYUD 1 year ago
parent e9037399f4
commit 27a5fea5db

@ -0,0 +1 @@
<button type="button" class="btn btn-primary mb-2" @onclick="Back">Retour</button>

@ -0,0 +1,18 @@
using Microsoft.AspNetCore.Components;
namespace Blazor.Components
{
public partial class BackButton
{
[Parameter]
public string RedirectionPage { get; set; }
[Inject]
public required NavigationManager NavigationManager { get; set; }
private void Back()
{
NavigationManager.NavigateTo(RedirectionPage, true);
}
}
}

@ -0,0 +1,6 @@

<div class="card text-center">
@CardHeader
@CardBody
@CardFooter
</div>

@ -0,0 +1,16 @@
using Microsoft.AspNetCore.Components;
namespace Blazor.Components
{
public partial class CardViewQuestion
{
[Parameter]
public RenderFragment CardBody { get; set; }
[Parameter]
public RenderFragment CardFooter { get; set; }
[Parameter]
public RenderFragment CardHeader { get; set; }
}
}

@ -1,32 +0,0 @@
@page "/displayquestions/{QuestionId:int}"
@if (question != null)
{
<div class="text-center pb-2">
<h3>Question n°@question.Id</h3>
</div>
<div class="text-center pb-5 mt-3">
<h5>@question.Content</h5>
</div>
<div class="container-fluid text-center justify-content-center row">
@foreach (var answer in answers)
{
<div class="col-3 text-center">
@if (answer.Id == question.IdAnswerGood)
{
<p class="text-success"><strong>@answer.Content</strong></p>
}
else
{
<p class="text-danger">@answer.Content</p>
}
</div>
}
</div>
}
else
{
<p>Question not found</p>
}

@ -1,21 +1,31 @@
@page "/editAdministrator/{Id:int}"
<h3>EditAdministrator</h3>
@using Blazor.Components;
<EditForm Model="@administratorModel" OnValidSubmit="@HandleValidSubmit">
<DataAnnotationsValidator />
<ValidationSummary />
<BackButton RedirectionPage="/administrators"></BackButton>
<p>
<label for="username">
Username:
<InputText id="username" @bind-Value="administratorModel.Username" />
</label>
<label for="hashedPassword">
Password:
<InputText id="hashedPassword" @bind-Value="administratorModel.HashedPassword" />
</label>
</p>
<div class="container text-center">
<div class="border border-dark p-4 d-inline-block">
<h3>EditAdministrator</h3>
<button type="submit">Submit</button>
</EditForm>
<EditForm Model="@administratorModel" OnValidSubmit="@HandleValidSubmit">
<DataAnnotationsValidator />
<ValidationSummary />
<div class="row mb-2">
<label for="username">
Username:
<InputText id="username" @bind-Value="administratorModel.Username" />
</label>
</div>
<div class="row mb-2">
<label for="hashedPassword">
Password:
<InputText id="hashedPassword" @bind-Value="administratorModel.HashedPassword" />
</label>
</div>
<button type="submit" class="btn btn-success mb-2">Submit</button>
</EditForm>
</div>
</div>

@ -1,18 +1,27 @@
@page "/editChapter/{Id:int}"
<h3>Edit Chapter</h3>
<EditForm Model="@chapterModel" OnValidSubmit="@HandleValidSubmit">
<DataAnnotationsValidator />
<ValidationSummary />
<p>
<label for="name">
Name:
<InputText id="name" @bind-Value="chapterModel.Name" />
</label>
</p>
<button type="submit">Submit</button>
</EditForm>
@using Blazor.Components;
<BackButton RedirectionPage="/chapters"></BackButton>
<div class="container text-center">
<div class="border border-dark p-4 d-inline-block">
<h3>Edit Chapter</h3>
<EditForm Model="@chapterModel" OnValidSubmit="@HandleValidSubmit">
<DataAnnotationsValidator />
<ValidationSummary />
<p>
<label for="name">
Name:
<InputText id="name" @bind-Value="chapterModel.Name" />
</label>
</p>
<button type="submit" class="btn btn-success mb-2">Submit</button>
</EditForm>
</div>
</div>

@ -1,21 +1,31 @@
@page "/editPlayer/{Id:int}"
<h3>Edit Player</h3>
@using Blazor.Components;
<EditForm Model="@playerModel" OnValidSubmit="@HandleValidSubmit">
<DataAnnotationsValidator />
<ValidationSummary />
<BackButton RedirectionPage="/players"></BackButton>
<p>
<label for="nickname">
Nickname:
<InputText id="nickname" @bind-Value="playerModel.Nickname" />
</label>
<label for="hashedPassword">
Password:
<InputText id="hashedPassword" @bind-Value="playerModel.HashedPassword" />
</label>
</p>
<div class="container text-center">
<div class="border border-dark p-4 d-inline-block">
<h3>Edit Player</h3>
<button type="submit">Submit</button>
</EditForm>
<EditForm Model="@playerModel" OnValidSubmit="@HandleValidSubmit">
<DataAnnotationsValidator />
<ValidationSummary />
<div class="row mb-2">
<label for="nickname">
Nickname:
<InputText id="nickname" @bind-Value="playerModel.Nickname" />
</label>
</div>
<div class="row mb-2"
<label for="hashedPassword">
Password:
<InputText id="hashedPassword" @bind-Value="playerModel.HashedPassword" />
</label>
</div>
<button type="submit" class="btn btn-success">Submit</button>
</EditForm>
</div>
</div>

@ -0,0 +1,37 @@
@page "/displayquestions/{QuestionId:int}"
@using Blazor.Components;
<CardViewQuestion>
<CardHeader>
<div class="text-center pb-2">
<h3>Question n°@question.Id</h3>
</div>
<div class="text-center pb-5 mt-3">
<h5>@question.Content</h5>
</div>
</CardHeader>
<CardBody>
<div class="container-fluid text-center justify-content-center row">
@foreach (var answer in answers)
{
<div class="col-3 text-center">
@if (answer.Id == question.IdAnswerGood)
{
<p class="text-success"><strong>@answer.Content</strong></p>
}
else
{
<p class="text-danger">@answer.Content</p>
}
</div>
}
</div>
</CardBody>
<CardFooter>
<div class="card-footer text-muted">
Chapitre : @question.ChapterName
</div>
<BackButton RedirectionPage="/questions"></BackButton>
</CardFooter>
</CardViewQuestion>

@ -1,11 +1,10 @@
using Blazor.Models;
using Blazor.Pages;
using Blazor.Pages.Questions;
using Blazor.ViewClasses;
using Microsoft.AspNetCore.Components;
using static System.Net.WebRequestMethods;
namespace Blazor.Components
namespace Blazor.Pages.Questions
{
public partial class DisplayQuestions
{
@ -30,7 +29,7 @@ namespace Blazor.Components
IEnumerable<Question> foundQuestions = questions.Where(q => q.Id == QuestionId);
foreach (var q in foundQuestions)
{
answers.Add(new Answer(q.A_id, q.A_content, q.Id));
Loading…
Cancel
Save