From f880ff537b0cf406300ec3a4b53968b9ec5077f9 Mon Sep 17 00:00:00 2001 From: majean5 Date: Fri, 16 Dec 2022 11:48:04 +0100 Subject: [PATCH] =?UTF-8?q?maintenant=20=C3=A7a=20marche=20pour=20de=20vra?= =?UTF-8?q?i?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/InventoryComp.razor.cs | 32 ++----------------- .../BlazorApp/Services/DataApiService.cs | 4 --- .../Controllers/CraftingController.cs | 21 ------------ 3 files changed, 3 insertions(+), 54 deletions(-) diff --git a/BlazorApp/BlazorApp/Components/InventoryComp.razor.cs b/BlazorApp/BlazorApp/Components/InventoryComp.razor.cs index 3356290..bda3518 100644 --- a/BlazorApp/BlazorApp/Components/InventoryComp.razor.cs +++ b/BlazorApp/BlazorApp/Components/InventoryComp.razor.cs @@ -31,19 +31,17 @@ namespace BlazorApp.Components private int totalItem; -<<<<<<< HEAD public bool IsSorted { get; set; } -======= + private int PageSize { get; set; } - private int CurrentPage { get; set; } - private bool IsSorted { get; set; } + private int CurrentPage { get; set; } ->>>>>>> ffa1fa821cc019ca5b6c2b58235c7474e8f62dd1 public InventoryComp() { Actions = new ObservableCollection(); + Actions.CollectionChanged += OnActionsCollectionChanged; this.InventoryItems = new List(new Item[18]); @@ -60,19 +58,6 @@ namespace BlazorApp.Components { return; } - -<<<<<<< HEAD - if (!e.CancellationToken.IsCancellationRequested && IsSorted ==false) - { - Items = await DataService.List(e.Page, e.PageSize); - totalItem = await DataService.Count(); - } - else - { - Items = await DataService.SortedList(e.Page, e.PageSize); - } - -======= if (!e.CancellationToken.IsCancellationRequested && !IsSorted) { Items = await DataService.List(e.Page, e.PageSize); @@ -86,25 +71,14 @@ namespace BlazorApp.Components PageSize = e.PageSize; Items = await DataService.SortedList(CurrentPage, PageSize); } ->>>>>>> ffa1fa821cc019ca5b6c2b58235c7474e8f62dd1 } private async Task SortByName() { -<<<<<<< HEAD - if (IsSorted) - { - IsSorted = false; - } - else - { - IsSorted = true; -======= if (!IsSorted) { IsSorted = true; Items = await DataService.SortedList(CurrentPage, PageSize); ->>>>>>> ffa1fa821cc019ca5b6c2b58235c7474e8f62dd1 } } diff --git a/BlazorApp/BlazorApp/Services/DataApiService.cs b/BlazorApp/BlazorApp/Services/DataApiService.cs index 7f6545a..78f44de 100644 --- a/BlazorApp/BlazorApp/Services/DataApiService.cs +++ b/BlazorApp/BlazorApp/Services/DataApiService.cs @@ -59,13 +59,9 @@ namespace BlazorApp.Services public async Task> SortedList(int currentPage, int pageSize) { -<<<<<<< HEAD - return await _http.GetFromJsonAsync>($"https://localhost:7234/api/Crafting/?currentPage={currentPage}&pageSize={pageSize}"); -======= List it = await _http.GetFromJsonAsync>($"https://localhost:7234/api/Crafting/all/"); it = it.OrderBy(i => i.DisplayName).ToList(); return it.GetRange((currentPage - 1) * 10, pageSize); ->>>>>>> ffa1fa821cc019ca5b6c2b58235c7474e8f62dd1 } diff --git a/BlazorApp/Minecraft.Crafting.Api/Controllers/CraftingController.cs b/BlazorApp/Minecraft.Crafting.Api/Controllers/CraftingController.cs index a916f63..11bb5fa 100644 --- a/BlazorApp/Minecraft.Crafting.Api/Controllers/CraftingController.cs +++ b/BlazorApp/Minecraft.Crafting.Api/Controllers/CraftingController.cs @@ -214,27 +214,6 @@ namespace Minecraft.Crafting.Api.Controllers return Task.FromResult(data.Skip((currentPage - 1) * pageSize).Take(pageSize).ToList()); } - /// - /// Get the sorted items with pagination. - /// - /// The current page. - /// Size of the page. - /// The sorted items. - [HttpGet] - [Route("")] - public Task> SortedList(int currentPage, int pageSize) - { - var data = JsonSerializer.Deserialize>(System.IO.File.ReadAllText("Data/items.json"), _jsonSerializerOptions); - - if (data == null) - { - throw new Exception("Unable to get the items."); - } - - var sorted = data.OrderBy(i => i.DisplayName); - return Task.FromResult(data.Skip((currentPage - 1) * pageSize).Take(pageSize).ToList()); - } - /// /// Resets the items. ///