working on edit form

This commit is contained in:
2026-03-22 21:01:54 +01:00
parent 7594d179a8
commit 65fa420306
9 changed files with 174 additions and 6 deletions
+1 -1
View File
@@ -42,7 +42,7 @@
<th>@pointOfInterest.Id</th>
<td>@pointOfInterest.Name</td>
<td>
<a class="btn btn-primary" href="@($"/pointofinterest/{pointOfInterest.Id}")">Détails</a>
<a class="btn btn-primary" href="@($"/city/{City.Id}/pointofinterest/{pointOfInterest.Id}")">Détails</a>
</td>
</tr>
}
+1
View File
@@ -23,6 +23,7 @@ namespace CityInfo.WEB.Pages
if(City == null)
{
NavigationManager.NavigateTo("/not-found");
return;
}
PointsOfInterest = await PointOfInterestDataService.GetPointsOfInterest(CityId);
}
@@ -0,0 +1,30 @@
@page "/city/{CityId:int}/pointofinterest/{PointOfInterestId:int}"
@if(PointOfInterest == null)
{
<Loading></Loading>
} else
{
<PageHeader Name="Point d'intéret" NameType="Détails" LinkType="LinkType.Edit" Link="@($"/city/{CityId}/pointofinterest/{PointOfInterestId}/edit")"></PageHeader>
<Card HeaderTitle="Informations sur le point d'intéret">
<div class="datagrid">
<div class="datagrid-item">
<div class="datagrid-title">Nom</div>
<div class="datagrid-content">@PointOfInterest.Name</div>
</div>
<div class="datagrid-item">
<div class="datagrid-title">Description</div>
<div class="datagrid-content">@PointOfInterest.Description</div>
</div>
@if(City != null)
{
<div class="datagrid-item">
<div class="datagrid-title">Ville liée</div>
<div class="datagrid-content"><a class="link link-primary" href="@($"/city/{CityId}")">@City.Name</a></div>
</div>
}
</div>
</Card>
}
@@ -0,0 +1,33 @@
using CityInfo.WEB.Models;
using CityInfo.WEB.Services;
using Microsoft.AspNetCore.Components;
namespace CityInfo.WEB.Pages
{
public partial class PointOfInterestDetails
{
[Inject]
public IPointOfInterestDataService PointOfInterestDataService { get; set; } = default!;
[Inject]
public ICityDataService CityDataService { get; set; } = default!;
[Inject]
public NavigationManager NavigationManager { get; set; } = default!;
[Parameter]
public int CityId { get; set; }
[Parameter]
public int PointOfInterestId { get; set; }
public PointOfInterest? PointOfInterest { get; set; }
public City? City { get; set; }
protected async override Task OnInitializedAsync()
{
PointOfInterest = await PointOfInterestDataService.GetPointOfInterest(CityId, PointOfInterestId);
if (PointOfInterest == null)
{
NavigationManager.NavigateTo("not-found");
return;
}
City = await CityDataService.GetCity(CityId);
}
}
}
@@ -0,0 +1,36 @@
@page "/city/{CityId:int}/pointofinterest/{PointOfInterestId:int}/edit"
@if (PointOfInterest == null)
{
<Loading></Loading>
}
else
{
<PageHeader Name="Point d'intéret" NameType="Modifier" LinkType="LinkType.Details" Link="@($"/city/{CityId}/pointofinterest/{PointOfInterestId}")"></PageHeader>
<Card HeaderTitle="Modifier le point d'intéret">
<EditForm Model="PointOfInterest" OnValidSubmit="HandleValidSubmit" OnInvalidSubmit="HandleInvalidSubmit">
<div>
<label for="PointOfInterestName" class="form-label">Nom</label>
<div class="input-icon">
<span class="input-icon-addon">
<i class="fa-solid fa-location-dot"></i>
</span>
<InputText id="PointOfInterestName" @bind-Value="PointOfInterest.Name" class="form-control"></InputText>
<ValidationMessage class="offset-md-3 col-md-8 text-danger" For="@(() => PointOfInterest.Name)" />
</div>
</div>
<div>
<label for="PointOfInterestDescription" class="form-label">Description</label>
<div class="input-icon">
<span class="input-icon-addon">
<i class="fa-solid fa-align-left"></i>
</span>
<InputText id="PointOfInterestDescription" @bind-Value="PointOfInterest.Description" class="form-control"></InputText>
<ValidationMessage class="offset-md-3 col-md-8 text-danger" For="@(() => PointOfInterest.Description)" />
</div>
</div>
</EditForm>
</Card>
}
@@ -0,0 +1,38 @@
using CityInfo.WEB.Models;
using CityInfo.WEB.Services;
using Microsoft.AspNetCore.Components;
namespace CityInfo.WEB.Pages
{
public partial class PointOfInterestEdit
{
[Inject]
public IPointOfInterestDataService PointOfInterestDataService { get; set; } = default!;
[Inject]
public ICityDataService CityDataService { get; set; } = default!;
[Inject]
public NavigationManager NavigationManager { get; set; } = default!;
[Parameter]
public int CityId { get; set; }
[Parameter]
public int PointOfInterestId { get; set; }
public PointOfInterest? PointOfInterest { get; set; }
protected async override Task OnInitializedAsync()
{
PointOfInterest = await PointOfInterestDataService.GetPointOfInterest(CityId, PointOfInterestId);
if (PointOfInterest == null)
{
NavigationManager.NavigateTo("not-found");
return;
}
}
private async Task HandleValidSubmit()
{
}
private async Task HandleInvalidSubmit()
{
}
}
}