diff --git a/CityInfo.API/CityInfo.db-shm b/CityInfo.API/CityInfo.db-shm index fe9ac28..986aa7c 100644 Binary files a/CityInfo.API/CityInfo.db-shm and b/CityInfo.API/CityInfo.db-shm differ diff --git a/CityInfo.API/CityInfo.db-wal b/CityInfo.API/CityInfo.db-wal index e69de29..3f05271 100644 Binary files a/CityInfo.API/CityInfo.db-wal and b/CityInfo.API/CityInfo.db-wal differ diff --git a/CityInfo.WEB/Pages/PointOfInterestEdit.razor b/CityInfo.WEB/Pages/PointOfInterestEdit.razor index 5f967a8..37bd4bb 100644 --- a/CityInfo.WEB/Pages/PointOfInterestEdit.razor +++ b/CityInfo.WEB/Pages/PointOfInterestEdit.razor @@ -7,30 +7,41 @@ else { - - -
- + @if (ReturnData) + { + +
@ReturnMessage
+
+ } else + { + + +
+ -
- - - - - +
+ + + + + +
-
-
- -
- - - - - +
+ +
+ + + + + +
-
- - - +
+ Annuler + +
+ + + } } \ No newline at end of file diff --git a/CityInfo.WEB/Pages/PointOfInterestEdit.razor.cs b/CityInfo.WEB/Pages/PointOfInterestEdit.razor.cs index 10b7dd9..d61f680 100644 --- a/CityInfo.WEB/Pages/PointOfInterestEdit.razor.cs +++ b/CityInfo.WEB/Pages/PointOfInterestEdit.razor.cs @@ -17,6 +17,10 @@ namespace CityInfo.WEB.Pages [Parameter] public int PointOfInterestId { get; set; } public PointOfInterest? PointOfInterest { get; set; } + + public bool ReturnData { get; set; } = false; + public string StatusClass { get; set; } = string.Empty; + public string ReturnMessage { get; set; } = string.Empty; protected async override Task OnInitializedAsync() { PointOfInterest = await PointOfInterestDataService.GetPointOfInterest(CityId, PointOfInterestId); @@ -28,10 +32,33 @@ namespace CityInfo.WEB.Pages } private async Task HandleValidSubmit() { + if(PointOfInterest != null) + { + var isAdded = await PointOfInterestDataService.UpdatePointOfInterest(CityId, PointOfInterest); + if (isAdded) + { + ReturnData = true; + ReturnMessage = "Le point d'intérer à été mis à jour."; + StatusClass = "alert-success"; + } else + { + ReturnData = true; + ReturnMessage = "Une erreur est survenue lors de la mise à jour du point d'intéret."; + StatusClass = "alert-danger"; + } + } else + { + ReturnData = true; + ReturnMessage = "Une erreur est arrivée avec les données entrées"; + StatusClass = "alert-danger"; + } } private async Task HandleInvalidSubmit() { + ReturnData = true; + ReturnMessage = "Les données entrées sont incorrectes."; + StatusClass = "alert-danger"; } } diff --git a/CityInfo.WEB/Services/PointOfInterestDataService.cs b/CityInfo.WEB/Services/PointOfInterestDataService.cs index 0eda2ae..76a6bf9 100644 --- a/CityInfo.WEB/Services/PointOfInterestDataService.cs +++ b/CityInfo.WEB/Services/PointOfInterestDataService.cs @@ -66,9 +66,18 @@ namespace CityInfo.WEB.Services } } - public Task UpdatePointOfInterest(int cityId, PointOfInterest pointOfInterest) + public async Task UpdatePointOfInterest(int cityId, PointOfInterest pointOfInterest) { - throw new NotImplementedException(); + try + { + var response = await _httpClient.PutAsJsonAsync($"/api/cities/{cityId}/pointsofinterest/{pointOfInterest.Id}", pointOfInterest); + return response.IsSuccessStatusCode; + } + catch (Exception ex) + { + _logger.LogError(ex, $"Erreur lors de la mise à jour du point d'intéret {pointOfInterest.Id}", pointOfInterest.Id); + return false; + } } } }