+
@if (!string.IsNullOrWhiteSpace(Item.ImageBase64))
{
@@ -17,7 +15,7 @@
}
else
{
-

+

}
\ No newline at end of file
diff --git a/Code/ProjetBlazor/Components/InventoryListImage.razor.cs b/Code/ProjetBlazor/Components/InventoryListImage.razor.cs
new file mode 100644
index 0000000..8088e94
--- /dev/null
+++ b/Code/ProjetBlazor/Components/InventoryListImage.razor.cs
@@ -0,0 +1,43 @@
+using ProjetBlazor.Models;
+using Microsoft.AspNetCore.Components;
+using ProjetBlazor.Components;
+
+namespace ProjetBlazor.Components
+{
+ public partial class InventoryListImage
+ {
+
+ [Parameter]
+ public Item Item { get; set; }
+
+ [CascadingParameter]
+ public Inventory Parent { get; set; }
+
+ internal void OnDragEnter()
+ {
+
+ Parent.Actions.Add(new InventoryAction("On drag enter", Item.Id, Item));
+ return;
+ }
+
+ internal void OnDragLeave()
+ {
+ Parent.Actions.Add(new InventoryAction("On drag leave", Item.Id, Item));
+ return;
+ }
+
+ internal void OnDrop()
+ {
+ Parent.Actions.Add(new InventoryAction("On drop", Item.Id, Item));
+ Parent.CurrentDragItem = null;
+ return;
+ }
+
+ private void OnDragStart()
+ {
+ Parent.CurrentDragItem = new InventoryItem(Item);
+ Parent.Actions.Add(new InventoryAction("On drag start", Item.Id, Item));
+ return;
+ }
+ }
+}
diff --git a/Code/ProjetBlazor/Components/GetItemInInventory.razor b/Code/ProjetBlazor/Components/ItemInventory.razor
similarity index 78%
rename from Code/ProjetBlazor/Components/GetItemInInventory.razor
rename to Code/ProjetBlazor/Components/ItemInventory.razor
index d49e5e3..b0445ee 100644
--- a/Code/ProjetBlazor/Components/GetItemInInventory.razor
+++ b/Code/ProjetBlazor/Components/ItemInventory.razor
@@ -1,20 +1,19 @@
-
@if(Items != null)
{
- @if(!string.IsNullOrWhiteSpace(Items.item.ImageBase64))
- {
-
+ @if(!string.IsNullOrWhiteSpace(Items.item.ImageBase64))
+ {
+
)
-
@Items.Stack
-
- }
- else
- {
+
@Items.Stack
+
+ }
+ else
+ {
@Items.Stack
diff --git a/Code/ProjetBlazor/Components/GetItemInInventory.razor.cs b/Code/ProjetBlazor/Components/ItemInventory.razor.cs
similarity index 74%
rename from Code/ProjetBlazor/Components/GetItemInInventory.razor.cs
rename to Code/ProjetBlazor/Components/ItemInventory.razor.cs
index a6690e1..4bc6c3e 100644
--- a/Code/ProjetBlazor/Components/GetItemInInventory.razor.cs
+++ b/Code/ProjetBlazor/Components/ItemInventory.razor.cs
@@ -1,23 +1,24 @@
-using Blazored.LocalStorage;
-using Blazorise;
+using ProjetBlazor.Models;
+using Blazored.LocalStorage;
+using Blazorise.Extensions;
using Microsoft.AspNetCore.Components;
-using ProjetBlazor.Models;
+using ProjetBlazor.Components;
namespace ProjetBlazor.Components
{
- public partial class GetItemInInventory
+ public partial class ItemInventory
{
[Parameter]
public bool NoDrop { get; set; }
[Parameter]
- public ItemInInventory? Items { get; set; }
+ public InventoryItem Items { get; set; }
[Parameter]
public int Index { get; set; }
[CascadingParameter]
- public ItemsList Parent { get; set; }
+ public Inventory Parent { get; set; }
[Inject]
public ILocalStorageService LocalStorage { get; set; }
@@ -32,13 +33,13 @@ namespace ProjetBlazor.Components
}
Parent.CurrentDragItem = this.Items;
- Parent.Actions.Add(new ActionInInventory("On drag start", this.Index, Items.item));
+ Parent.Actions.Add(new InventoryAction("On drag start",this.Index,Items.item));
this.Items = null;
- Parent.inventory.inventoryItems[this.Index] = null;
+ Parent.inventory.inventoryItems[this.Index] = null ;
await LocalStorage.RemoveItemAsync("data" + this.Index);
await LocalStorage.RemoveItemAsync("stack" + this.Index);
}
-
+
public async Task OnDropAsync()
{
@@ -48,13 +49,13 @@ namespace ProjetBlazor.Components
return;
}
- if (this.Items == null)
+ if(this.Items == null)
{
this.Items = Parent.CurrentDragItem;
Parent.CurrentDragItem = null;
await LocalStorage.SetItemAsync
- ("data" + this.Index, this.Items.item);
await LocalStorage.SetItemAsync("stack" + this.Index, this.Items.Stack);
- Parent.Actions.Add(new ActionInInventory("On drag drop", this.Index, Items.item));
+ Parent.Actions.Add(new InventoryAction("On drag drop",this.Index,Items.item));
return;
}
@@ -64,11 +65,11 @@ namespace ProjetBlazor.Components
Parent.CurrentDragItem = null;
await LocalStorage.SetItemAsync
- ("data" + this.Index, this.Items.item);
await LocalStorage.SetItemAsync("stack" + this.Index, this.Items.Stack);
- Parent.Actions.Add(new ActionInInventory("On drag drop", this.Index, Items.item));
+ Parent.Actions.Add(new InventoryAction("On drag drop",this.Index,Items.item));
return;
}
else
- {
+ {
int total = Parent.CurrentDragItem.Stack + this.Items.Stack;
if (total > this.Items.item.StackSize)
{
@@ -77,7 +78,7 @@ namespace ProjetBlazor.Components
await LocalStorage.SetItemAsync
- ("data" + this.Index, this.Items.item);
await LocalStorage.SetItemAsync("stack" + this.Index, this.Items.Stack);
- Parent.Actions.Add(new ActionInInventory("On drag drop", this.Index, Items.item));
+ Parent.Actions.Add(new InventoryAction("On drag drop",this.Index,Items.item));
return;
}
else
@@ -86,7 +87,7 @@ namespace ProjetBlazor.Components
Parent.CurrentDragItem = null;
await LocalStorage.SetItemAsync
- ("data" + this.Index, this.Items.item);
await LocalStorage.SetItemAsync("stack" + this.Index, this.Items.Stack);
- Parent.Actions.Add(new ActionInInventory("On drag drop", this.Index, Items.item));
+ Parent.Actions.Add(new InventoryAction("On drag drop",this.Index,Items.item));
return;
}
}
@@ -94,13 +95,13 @@ namespace ProjetBlazor.Components
internal void OnDragEnter()
{
if (this.Items == null) return;
- Parent.Actions.Add(new ActionInInventory("Drag Enter", this.Index, Items.item));
+ Parent.Actions.Add(new InventoryAction("Drag Enter",this.Index,Items.item));
}
internal void OnDragLeave()
{
if (this.Items == null) return;
- Parent.Actions.Add(new ActionInInventory("Drag Leave", this.Index, Items.item));
+ Parent.Actions.Add(new InventoryAction("Drag Leave",this.Index,Items.item));
}
@@ -117,14 +118,14 @@ namespace ProjetBlazor.Components
if (item != null)
{
- this.Items = new Models.ItemInInventory(item, stack);
+ this.Items = new Models.InventoryItem(item, stack);
}
else
{
this.Items = null;
}
- StateHasChanged();
- return;
+ StateHasChanged();
+ return;
}
}
}
diff --git a/Code/ProjetBlazor/Components/GetItemInInventory.razor.css b/Code/ProjetBlazor/Components/ItemInventory.razor.css
similarity index 90%
rename from Code/ProjetBlazor/Components/GetItemInInventory.razor.css
rename to Code/ProjetBlazor/Components/ItemInventory.razor.css
index 10796f3..fb18436 100644
--- a/Code/ProjetBlazor/Components/GetItemInInventory.razor.css
+++ b/Code/ProjetBlazor/Components/ItemInventory.razor.css
@@ -1,5 +1,5 @@
.item {
- margin: 10% 10% 10% 10%;
+ margin: 8% 8% 8% 8%;
width: 100px;
height: 100px;
border: 1px solid;
diff --git a/Code/ProjetBlazor/Components/ItemsList.razor.cs b/Code/ProjetBlazor/Components/ItemsList.razor.cs
deleted file mode 100644
index 4936c66..0000000
--- a/Code/ProjetBlazor/Components/ItemsList.razor.cs
+++ /dev/null
@@ -1,69 +0,0 @@
-using Blazored.Modal.Services;
-using Microsoft.AspNetCore.Components;
-using Microsoft.Extensions.Localization;
-using Microsoft.JSInterop;
-using ProjetBlazor.Models;
-using ProjetBlazor.Services;
-using System.Collections.ObjectModel;
-using System.Collections.Specialized;
-
-namespace ProjetBlazor.Components
-{
- public partial class ItemsList
- {
- public Models.Inventory inventory = new Models.Inventory();
- public ObservableCollection Actions { get; set; }
- public ItemInInventory CurrentDragItem { get; set; }
-
- [Parameter]
- public List
- Items { get; set; }
-
- ///
- /// Gets or sets the java script runtime.
- ///
- [Inject]
- internal IJSRuntime JavaScriptRuntime { get; set; }
-
- [Inject]
-
- public IStringLocalizer Localizer { get; set; }
-
-
- private void OnActionsCollectionChanged(object? sender, NotifyCollectionChangedEventArgs e)
- {
- _ = JavaScriptRuntime.InvokeVoidAsync("Crafting.AddActions", e.NewItems);
- }
-
- private List
- ? items;
-
- private int totalItem;
-
- [Inject]
- public IDataService DataService { get; set; }
-
- [Inject]
- public IWebHostEnvironment WebHostEnvironment { get; set; }
-
- [Inject]
- public NavigationManager NavigationManager { get; set; }
-
- [CascadingParameter]
- public IModalService Modal { get; set; }
- public object Action { get; internal set; }
-
- public ItemsList()
- {
- Actions = new ObservableCollection();
- Actions.CollectionChanged += OnActionsCollectionChanged;
- }
-
-
- protected override async Task OnInitializedAsync()
- {
- items = await DataService.GetAll();
- totalItem = await DataService.Count();
- await base.OnInitializedAsync();
- }
-
- }
-}
diff --git a/Code/ProjetBlazor/Components/ShowItems.razor b/Code/ProjetBlazor/Components/ShowItems.razor
new file mode 100644
index 0000000..e8fccfd
--- /dev/null
+++ b/Code/ProjetBlazor/Components/ShowItems.razor
@@ -0,0 +1,11 @@
+@typeparam TItem
+
+
+ @if ((Items?.Count ?? 0) != 0)
+ {
+ @foreach (var item in Items)
+ {
+ @ShowTemplate(item);
+ }
+ }
+
\ No newline at end of file
diff --git a/Code/ProjetBlazor/Components/ShowItems.razor.cs b/Code/ProjetBlazor/Components/ShowItems.razor.cs
new file mode 100644
index 0000000..3dfcbf0
--- /dev/null
+++ b/Code/ProjetBlazor/Components/ShowItems.razor.cs
@@ -0,0 +1,13 @@
+using Microsoft.AspNetCore.Components;
+
+namespace ProjetBlazor.Components
+{
+ public partial class ShowItems
+ {
+ [Parameter]
+ public List Items { get; set; }
+
+ [Parameter]
+ public RenderFragment ShowTemplate { get; set; }
+ }
+}
diff --git a/Code/ProjetBlazor/Models/Inventory.cs b/Code/ProjetBlazor/Models/Inventory.cs
deleted file mode 100644
index 3f4a273..0000000
--- a/Code/ProjetBlazor/Models/Inventory.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-namespace ProjetBlazor.Models
-{
- public partial class Inventory
- {
-
- static public int size = 18;
-
- ///
- /// List of inventory items.
- ///
- public List inventoryItems = new List(new ItemInInventory[size]);
-
- ///
- /// Constructor for InventoryList.
- ///
- public Inventory()
- {
- inventoryItems[0] = new ItemInInventory();
- }
- }
-}
-
diff --git a/Code/ProjetBlazor/Models/ItemInInventory.cs b/Code/ProjetBlazor/Models/InventoryItem.cs
similarity index 74%
rename from Code/ProjetBlazor/Models/ItemInInventory.cs
rename to Code/ProjetBlazor/Models/InventoryItem.cs
index ba26c6f..01f0ea0 100644
--- a/Code/ProjetBlazor/Models/ItemInInventory.cs
+++ b/Code/ProjetBlazor/Models/InventoryItem.cs
@@ -1,6 +1,11 @@
-namespace ProjetBlazor.Models
-{
- public class ItemInInventory
+using System.Collections;
+
+namespace ProjetBlazor.Models
+{
+ ///
+ /// Represents an item in a player's inventory.
+ ///
+ public class InventoryItem
{
public Item item;
int stack;
@@ -13,7 +18,7 @@
///
/// Constructor for InventoryItem with no parameters.
///
- public ItemInInventory()
+ public InventoryItem()
{
item = new Item();
Stack = 64;
@@ -22,7 +27,7 @@
/// Constructor for InventoryItem with a single item.
///
/// The item.
- public ItemInInventory(Item item)
+ public InventoryItem(Item item)
{
this.item = item;
Stack = 1;
@@ -33,7 +38,7 @@
///
/// The item
/// The number of items in the stack.
- public ItemInInventory(Item item, int stock)
+ public InventoryItem(Item item, int stock)
{
this.item = item;
Stack = stock;
diff --git a/Code/ProjetBlazor/Models/InventoryList.cs b/Code/ProjetBlazor/Models/InventoryList.cs
new file mode 100644
index 0000000..e6addfa
--- /dev/null
+++ b/Code/ProjetBlazor/Models/InventoryList.cs
@@ -0,0 +1,26 @@
+using Microsoft.AspNetCore.Http.Features;
+
+namespace ProjetBlazor.Models
+{
+ ///
+ /// Represents a list of items in a player's inventory.
+ ///
+ public partial class InventoryList
+ {
+
+ public static readonly int Size = 27;
+
+ ///
+ /// List of inventory items.
+ ///
+ public List inventoryItems = new List(new InventoryItem[Size]);
+
+ ///
+ /// Constructor for InventoryList.
+ ///
+ public InventoryList()
+ {
+ inventoryItems[0] = new InventoryItem();
+ }
+ }
+}
diff --git a/Code/ProjetBlazor/Models/Item.cs b/Code/ProjetBlazor/Models/Item.cs
index 9e31dcf..b08ad37 100644
--- a/Code/ProjetBlazor/Models/Item.cs
+++ b/Code/ProjetBlazor/Models/Item.cs
@@ -1,16 +1,20 @@
namespace ProjetBlazor.Models
-{
+{
+ ///
+ /// Represents an item.
+ ///
public class Item
{
public int Id { get; set; }
- public string? DisplayName { get; set; }
- public string? Name { get; set; }
+ public string DisplayName { get; set; }
+ public string Name { get; set; }
public int StackSize { get; set; }
public int MaxDurability { get; set; }
- public List? EnchantCategories { get; set; }
- public List? RepairWith { get; set; }
- public DateTime? CreatedDate { get; set; }
+ public List EnchantCategories { get; set; }
+ public List RepairWith { get; set; }
+ public DateTime CreatedDate { get; set; }
public DateTime? UpdatedDate { get; set; }
- public string? ImageBase64 { get; set; }
+ public string ImageBase64 { get; set; }
+
}
-}
\ No newline at end of file
+}
diff --git a/Code/ProjetBlazor/Models/ItemModel.cs b/Code/ProjetBlazor/Models/ItemModel.cs
index 2b8e113..f59d84c 100644
--- a/Code/ProjetBlazor/Models/ItemModel.cs
+++ b/Code/ProjetBlazor/Models/ItemModel.cs
@@ -1,40 +1,41 @@
using System.ComponentModel.DataAnnotations;
namespace ProjetBlazor.Models
-{
+{
+ ///
+ /// Model for creating or updating an item.
+ ///
public class ItemModel
{
public int Id { get; set; }
[Required]
- [StringLength(50, ErrorMessage = "Le nom affiché ne doit pas dépasser 50 caractères.")]
- public string? DisplayName { get; set; }
+ [StringLength(50, ErrorMessage = "The display name must not exceed 50 characters.")]
+ public string DisplayName { get; set; }
[Required]
- [StringLength(50, ErrorMessage = "Le nom ne doit pas dépasser 50 caractères.")]
- [RegularExpression(@"^[a-z''-'\s]{1,40}$", ErrorMessage = "Seulement les caractères en minuscule sont acceptées.")]
- public string? Name { get; set; }
+ [StringLength(50, ErrorMessage = "The name must not exceed 50 characters.")]
+ [RegularExpression(@"^[a-z''-'\s]{1,40}$", ErrorMessage = "Only lowercase characters are accepted.")]
+ public string Name { get; set; }
[Required]
[Range(1, 64)]
public int StackSize { get; set; }
[Required]
- [Range(1, 3000)]
+ [Range(1, 125)]
public int MaxDurability { get; set; }
- public List? EnchantCategories { get; set; }
+ public List EnchantCategories { get; set; }
- public List? RepairWith { get; set; }
+ public List RepairWith { get; set; }
[Required]
- [Range(typeof(bool), "true", "true", ErrorMessage = "Vous devez accepter les conditions.")]
+ [Range(typeof(bool), "true", "true", ErrorMessage = "You must agree to the terms.")]
public bool AcceptCondition { get; set; }
- [Required(ErrorMessage = "L'image de l'item est obligatoire !")]
- public byte[]? ImageContent { get; set; }
-
- public string? ImageBase64 { get; set; }
+ [Required(ErrorMessage = "The image of the item is mandatory!")]
+ public byte[] ImageContent { get; set; }
+ public string ImageBase64 { get; set; }
}
}
-
diff --git a/Code/ProjetBlazor/Pages/Inventory.razor.cs b/Code/ProjetBlazor/Pages/Inventory.razor.cs
deleted file mode 100644
index af67799..0000000
--- a/Code/ProjetBlazor/Pages/Inventory.razor.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-using Microsoft.AspNetCore.Components;
-using Microsoft.Extensions.Localization;
-using ProjetBlazor.Components;
-using ProjetBlazor.Models;
-using ProjetBlazor.Services;
-using System.Collections.Generic;
-
-namespace ProjetBlazor.Pages
-{
- public partial class Inventory
- {
- [Inject]
- public IDataService DataService { get; set; }
-
- public List- Items { get; set; } = new List
- ();
-
- protected override async Task OnAfterRenderAsync(bool firstRender)
- {
- _ = base.OnAfterRenderAsync(firstRender);
-
- if (!firstRender)
- {
- return;
- }
-
- Items = await DataService.List(0, await DataService.Count());
-
- StateHasChanged();
- }
- }
-}
diff --git a/Code/ProjetBlazor/Pages/Inventory.razor b/Code/ProjetBlazor/Pages/InventoryPages.razor
similarity index 80%
rename from Code/ProjetBlazor/Pages/Inventory.razor
rename to Code/ProjetBlazor/Pages/InventoryPages.razor
index c8faaad..cd9750c 100644
--- a/Code/ProjetBlazor/Pages/Inventory.razor
+++ b/Code/ProjetBlazor/Pages/InventoryPages.razor
@@ -8,5 +8,5 @@
-
+
\ No newline at end of file
diff --git a/Code/ProjetBlazor/Resources/Components.ItemsList.fr-FR.resx b/Code/ProjetBlazor/Resources/Components .Inventory.fr-FR.resx
similarity index 100%
rename from Code/ProjetBlazor/Resources/Components.ItemsList.fr-FR.resx
rename to Code/ProjetBlazor/Resources/Components .Inventory.fr-FR.resx
diff --git a/Code/ProjetBlazor/Resources/Components.ItemsList.en-US.resx b/Code/ProjetBlazor/Resources/Components.Inventory.en-US.resx
similarity index 100%
rename from Code/ProjetBlazor/Resources/Components.ItemsList.en-US.resx
rename to Code/ProjetBlazor/Resources/Components.Inventory.en-US.resx
diff --git a/Code/ProjetBlazor/Resources/Components.InventoryList.en-US.resx b/Code/ProjetBlazor/Resources/Components.InventoryList.en-US.resx
new file mode 100644
index 0000000..1e4ffdc
--- /dev/null
+++ b/Code/ProjetBlazor/Resources/Components.InventoryList.en-US.resx
@@ -0,0 +1,138 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ Actions
+
+
+ Item Picture
+
+
+ My Inventory :
+
+
+ List of Items :
+
+
+ Name
+
+
+ Stack Size
+
+
\ No newline at end of file
diff --git a/Code/ProjetBlazor/Resources/Components.InventoryList.fr-FR.resx b/Code/ProjetBlazor/Resources/Components.InventoryList.fr-FR.resx
new file mode 100644
index 0000000..02ac5c4
--- /dev/null
+++ b/Code/ProjetBlazor/Resources/Components.InventoryList.fr-FR.resx
@@ -0,0 +1,138 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ Actions
+
+
+ Image de l'item
+
+
+ Mon Inventaire :
+
+
+ Liste des Items :
+
+
+ Nom
+
+
+ Taille du Stack
+
+
\ No newline at end of file
diff --git a/Code/ProjetBlazor/Services/DataApiService.cs b/Code/ProjetBlazor/Services/DataApiService.cs
index b53b2e5..372b591 100644
--- a/Code/ProjetBlazor/Services/DataApiService.cs
+++ b/Code/ProjetBlazor/Services/DataApiService.cs
@@ -40,7 +40,7 @@ namespace Blazor.Services
/// Task representing the asynchronous operation, returning a list of items.
public async Task> List(int currentPage, int pageSize)
{
- return await _http.GetFromJsonAsync>($"https://codefirst.iut.uca.fr/containers/container-blazor-web-api-marcchevaldonne/api/Crafting/?currentPage={currentPage}&pageSize={pageSize}");
+ return await _http.GetFromJsonAsync>($"https://localhost:7234/api/Crafting/?currentPage={currentPage}&pageSize={pageSize}");
}
///
@@ -59,7 +59,7 @@ namespace Blazor.Services
/// Task representing the asynchronous operation, returning the item with the specified ID.
public async Task- GetById(int id)
{
- return await _http.GetFromJsonAsync
- ($"https://codefirst.iut.uca.fr/containers/container-blazor-web-api-marcchevaldonne/api/Crafting/{id}");
+ return await _http.GetFromJsonAsync
- ($"https://localhost:7234/api/Crafting/{id}");
}
}
}