diff --git a/Blazor/Blazor/Factories/ItemFactory.cs b/Blazor/Blazor/Factories/ItemFactory.cs
index d2c094e..6cba4de 100644
--- a/Blazor/Blazor/Factories/ItemFactory.cs
+++ b/Blazor/Blazor/Factories/ItemFactory.cs
@@ -1,11 +1,20 @@
using Blazor.Models;
namespace Blazor.Factories
-{
+{
+ ///
+ /// A static factory for creating and updating ItemModel and Item.
+ ///
public static class ItemFactory
- {
+ {
+ ///
+ /// Converts an Item to an ItemModel
+ ///
+ /// The item to convert.
+ /// The image content of the ItemModel
+ /// An ItemModel with the same properties as the item.
public static ItemModel ToModel(Item item, byte[] imageContent)
- {
+ {
return new ItemModel
{
Id = item.Id,
@@ -20,6 +29,11 @@ namespace Blazor.Factories
};
}
+ ///
+ /// Creates an Item from an ItemModel.
+ ///
+ /// The ItemModel to create the Itemfrom.
+ /// An Item with the same properties as the ItemModel.
public static Item Create(ItemModel model)
{
return new Item
@@ -35,7 +49,12 @@ namespace Blazor.Factories
ImageBase64 = Convert.ToBase64String(model.ImageContent)
};
}
-
+
+ ///
+ /// Updates an Item with the properties of an ItemModel.
+ ///
+ /// The Item to update
+ /// The ItemModel used to update the item
public static void Update(Item item, ItemModel model)
{
item.DisplayName = model.DisplayName;
diff --git a/Blazor/Blazor/Modals/DeleteConfirmation.razor.cs b/Blazor/Blazor/Modals/DeleteConfirmation.razor.cs
index 846860b..0d262a0 100644
--- a/Blazor/Blazor/Modals/DeleteConfirmation.razor.cs
+++ b/Blazor/Blazor/Modals/DeleteConfirmation.razor.cs
@@ -5,18 +5,29 @@ using Blazored.Modal.Services;
using Microsoft.AspNetCore.Components;
namespace Blazor.Modals
-{
+{
+ ///
+ /// Partial class for the delete confirmation modal.
+ ///
public partial class DeleteConfirmation
- {
+ {
+ ///
+ /// The modal instance
+ ///
[CascadingParameter]
public BlazoredModalInstance ModalInstance { get; set; }
+
[Inject]
public IDataService DataService { get; set; }
+ ///
+ /// The id of the item to delete
+ ///
[Parameter]
public int Id { get; set; }
+
private Item item = new Item();
protected override async Task OnInitializedAsync()
@@ -25,11 +36,17 @@ namespace Blazor.Modals
item = await DataService.GetById(Id);
}
+ ///
+ /// Confirms the deletion of the item.
+ ///
void ConfirmDelete()
{
ModalInstance.CloseAsync(ModalResult.Ok(true));
}
+ ///
+ /// Cancels the deletion of the item.
+ ///
void Cancel()
{
ModalInstance.CancelAsync();
diff --git a/Blazor/Blazor/Models/InventoryItem.cs b/Blazor/Blazor/Models/InventoryItem.cs
index 325573a..d548393 100644
--- a/Blazor/Blazor/Models/InventoryItem.cs
+++ b/Blazor/Blazor/Models/InventoryItem.cs
@@ -1,24 +1,43 @@
using System.Collections;
namespace Blazor.Models
-{
+{
+ ///
+ /// Represents an item in a player's inventory.
+ ///
public class InventoryItem
{
public Item item;
int stack;
+
+ ///
+ /// The number of items in the stack.
+ ///
public int Stack { get; set; }
+ ///
+ /// Constructor for InventoryItem with no parameters.
+ ///
public InventoryItem()
{
item = new Item();
Stack = 64;
}
+ ///
+ /// Constructor for InventoryItem with a single item.
+ ///
+ /// The item.
public InventoryItem(Item item)
{
this.item = item;
Stack = 1;
}
+ ///
+ /// Constructor for InventoryItem with a stack of items.
+ ///
+ /// The item
+ /// The number of items in the stack.
public InventoryItem(Item item, int stock)
{
this.item = item;
diff --git a/Blazor/Blazor/Models/InventoryList.cs b/Blazor/Blazor/Models/InventoryList.cs
index 6dfd9fb..1fce119 100644
--- a/Blazor/Blazor/Models/InventoryList.cs
+++ b/Blazor/Blazor/Models/InventoryList.cs
@@ -1,12 +1,23 @@
using Microsoft.AspNetCore.Http.Features;
namespace Blazor.Models
-{
+{
+ ///
+ /// Represents a list of items in a player's inventory.
+ ///
public partial class InventoryList
- {
+ {
+
static public int size = 18;
+
+ ///
+ /// List of inventory items.
+ ///
public List inventoryItems = new List(new InventoryItem[size]);
+ ///
+ /// Constructor for InventoryList.
+ ///
public InventoryList()
{
inventoryItems[0] = new InventoryItem();
diff --git a/Blazor/Blazor/Models/Item.cs b/Blazor/Blazor/Models/Item.cs
index ad086c3..e835c38 100644
--- a/Blazor/Blazor/Models/Item.cs
+++ b/Blazor/Blazor/Models/Item.cs
@@ -1,5 +1,8 @@
namespace Blazor.Models
-{
+{
+ ///
+ /// Represents an item.
+ ///
public class Item
{
public int Id { get; set; }
@@ -12,6 +15,10 @@
public DateTime CreatedDate { get; set; }
public DateTime? UpdatedDate { get; set; }
public string ImageBase64 { get; set; }
+
+ ///
+ /// Constructor for Item.
+ ///
public Item()
{
Id = 2;
diff --git a/Blazor/Blazor/Models/ItemModel.cs b/Blazor/Blazor/Models/ItemModel.cs
index 21bc32b..0bf9353 100644
--- a/Blazor/Blazor/Models/ItemModel.cs
+++ b/Blazor/Blazor/Models/ItemModel.cs
@@ -1,7 +1,10 @@
using System.ComponentModel.DataAnnotations;
namespace Blazor.Models
-{
+{
+ ///
+ /// Model for creating or updating an item.
+ ///
public class ItemModel
{
public int Id { get; set; }
diff --git a/Blazor/Blazor/Pages/Index.razor.cs b/Blazor/Blazor/Pages/Index.razor.cs
index 0a77a38..d925abe 100644
--- a/Blazor/Blazor/Pages/Index.razor.cs
+++ b/Blazor/Blazor/Pages/Index.razor.cs
@@ -4,16 +4,32 @@ using Blazor.Services;
using Microsoft.AspNetCore.Components;
namespace Blazor.Pages
-{
+{
+ ///
+ /// Partial class for the Index page.
+ ///
public partial class Index
- {
+ {
+ ///
+ /// The data service for accessing item and recipe data.
+ ///
[Inject]
public IDataService DataService { get; set; }
+ ///
+ /// List of items to display on the page.
+ ///
public List- Items { get; set; } = new List
- ();
+ ///
+ /// List of crafting recipes possible.
+ ///
private List Recipes { get; set; } = new List();
+ ///
+ /// Method that runs after the component has finished rendering.
+ ///
+ /// Indicates whether this is the first render of the component.
protected override async Task OnAfterRenderAsync(bool firstRender)
{
base.OnAfterRenderAsync(firstRender);
diff --git a/Blazor/Blazor/Pages/InventoryPage.razor.cs b/Blazor/Blazor/Pages/InventoryPage.razor.cs
index 49b667b..499109f 100644
--- a/Blazor/Blazor/Pages/InventoryPage.razor.cs
+++ b/Blazor/Blazor/Pages/InventoryPage.razor.cs
@@ -3,10 +3,15 @@ using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.Localization;
namespace Blazor.Pages
-{
+{
+ ///
+ /// Partial class for the InventoryPage.
+ ///
public partial class InventoryPage
{
-
+ ///
+ /// The localizer for the InventoryPage.
+ ///
[Inject]
public IStringLocalizer Localizer { get; set; }
diff --git a/Blazor/Blazor/Pages/List.razor.cs b/Blazor/Blazor/Pages/List.razor.cs
index 5a0a5ce..5a9dd37 100644
--- a/Blazor/Blazor/Pages/List.razor.cs
+++ b/Blazor/Blazor/Pages/List.razor.cs
@@ -9,9 +9,12 @@ using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.Localization;
namespace Blazor.Pages
-{
+{
+ ///
+ /// Partial class for the List page.
+ ///
public partial class List
- {
+ {
private List
- items;
private int totalItem;
@@ -22,15 +25,29 @@ namespace Blazor.Pages
[Inject]
public IWebHostEnvironment WebHostEnvironment { get; set; }
+ ///
+ /// The navigation manager for navigating between pages.
+ ///
[Inject]
public NavigationManager NavigationManager { get; set; }
-
+
+ ///
+ /// The modal service for displaying modal dialogs
+ ///
[CascadingParameter]
public IModalService Modal { get; set; }
+ ///
+ /// The localizer for the List page.
+ ///
[Inject]
public IStringLocalizer
Localizer { get; set; }
+ ///
+ /// Event handler for reading data in the data grid.
+ ///
+ /// The event arguments.
+ /// A task representing the asynchronous operation.
private async Task OnReadData(DataGridReadDataEventArgs- e)
{
if (e.CancellationToken.IsCancellationRequested)
@@ -45,6 +62,10 @@ namespace Blazor.Pages
}
}
+ ///
+ /// Event handler for deleting an item.
+ ///
+ /// The id of the item to delete.
private async void OnDelete(int id)
{
var parameters = new ModalParameters();