add docs for a lot of class
continuous-integration/drone/push Build is passing Details

master
remrem 2 years ago
parent 7cba21a0e4
commit c6439a5562

@ -2,8 +2,17 @@
namespace Blazor.Factories
{
/// <summary>
/// A static factory for creating and updating ItemModel and Item.
/// </summary>
public static class ItemFactory
{
/// <summary>
/// Converts an Item to an ItemModel
/// </summary>
/// <param name="item">The item to convert.</param>
/// <param name="imageContent">The image content of the ItemModel</param>
/// <returns>An ItemModel with the same properties as the item.</returns>
public static ItemModel ToModel(Item item, byte[] imageContent)
{
return new ItemModel
@ -20,6 +29,11 @@ namespace Blazor.Factories
};
}
/// <summary>
/// Creates an Item from an ItemModel.
/// </summary>
/// <param name="model">The ItemModel to create the Itemfrom.</param>
/// <returns>An Item with the same properties as the ItemModel.</returns>
public static Item Create(ItemModel model)
{
return new Item
@ -36,6 +50,11 @@ namespace Blazor.Factories
};
}
/// <summary>
/// Updates an Item with the properties of an ItemModel.
/// </summary>
/// <param name="item"> The Item to update </param>
/// <param name="model"> The ItemModel used to update the item </param>
public static void Update(Item item, ItemModel model)
{
item.DisplayName = model.DisplayName;

@ -6,17 +6,28 @@ using Microsoft.AspNetCore.Components;
namespace Blazor.Modals
{
/// <summary>
/// Partial class for the delete confirmation modal.
/// </summary>
public partial class DeleteConfirmation
{
/// <summary>
/// The modal instance
/// </summary>
[CascadingParameter]
public BlazoredModalInstance ModalInstance { get; set; }
[Inject]
public IDataService DataService { get; set; }
/// <summary>
/// The id of the item to delete
/// </summary>
[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);
}
/// <summary>
/// Confirms the deletion of the item.
/// </summary>
void ConfirmDelete()
{
ModalInstance.CloseAsync(ModalResult.Ok(true));
}
/// <summary>
/// Cancels the deletion of the item.
/// </summary>
void Cancel()
{
ModalInstance.CancelAsync();

@ -2,23 +2,42 @@
namespace Blazor.Models
{
/// <summary>
/// Represents an item in a player's inventory.
/// </summary>
public class InventoryItem
{
public Item item;
int stack;
/// <summary>
/// The number of items in the stack.
/// </summary>
public int Stack { get; set; }
/// <summary>
/// Constructor for InventoryItem with no parameters.
/// </summary>
public InventoryItem()
{
item = new Item();
Stack = 64;
}
/// <summary>
/// Constructor for InventoryItem with a single item.
/// </summary>
/// <param name="item">The item.</param>
public InventoryItem(Item item)
{
this.item = item;
Stack = 1;
}
/// <summary>
/// Constructor for InventoryItem with a stack of items.
/// </summary>
/// <param name="item">The item</param>
/// <param name="stock">The number of items in the stack.</param>
public InventoryItem(Item item, int stock)
{
this.item = item;

@ -2,11 +2,22 @@
namespace Blazor.Models
{
/// <summary>
/// Represents a list of items in a player's inventory.
/// </summary>
public partial class InventoryList
{
static public int size = 18;
/// <summary>
/// List of inventory items.
/// </summary>
public List<InventoryItem> inventoryItems = new List<InventoryItem>(new InventoryItem[size]);
/// <summary>
/// Constructor for InventoryList.
/// </summary>
public InventoryList()
{
inventoryItems[0] = new InventoryItem();

@ -1,5 +1,8 @@
namespace Blazor.Models
{
/// <summary>
/// Represents an item.
/// </summary>
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; }
/// <summary>
/// Constructor for Item.
/// </summary>
public Item()
{
Id = 2;

@ -2,6 +2,9 @@
namespace Blazor.Models
{
/// <summary>
/// Model for creating or updating an item.
/// </summary>
public class ItemModel
{
public int Id { get; set; }

@ -5,15 +5,31 @@ using Microsoft.AspNetCore.Components;
namespace Blazor.Pages
{
/// <summary>
/// Partial class for the Index page.
/// </summary>
public partial class Index
{
/// <summary>
/// The data service for accessing item and recipe data.
/// </summary>
[Inject]
public IDataService DataService { get; set; }
/// <summary>
/// List of items to display on the page.
/// </summary>
public List<Item> Items { get; set; } = new List<Item>();
/// <summary>
/// List of crafting recipes possible.
/// </summary>
private List<CraftingRecipe> Recipes { get; set; } = new List<CraftingRecipe>();
/// <summary>
/// Method that runs after the component has finished rendering.
/// </summary>
/// <param name="firstRender">Indicates whether this is the first render of the component.</param>
protected override async Task OnAfterRenderAsync(bool firstRender)
{
base.OnAfterRenderAsync(firstRender);

@ -4,9 +4,14 @@ using Microsoft.Extensions.Localization;
namespace Blazor.Pages
{
/// <summary>
/// Partial class for the InventoryPage.
/// </summary>
public partial class InventoryPage
{
/// <summary>
/// The localizer for the InventoryPage.
/// </summary>
[Inject]
public IStringLocalizer<InventoryPage> Localizer { get; set; }

@ -10,6 +10,9 @@ using Microsoft.Extensions.Localization;
namespace Blazor.Pages
{
/// <summary>
/// Partial class for the List page.
/// </summary>
public partial class List
{
private List<Item> items;
@ -22,15 +25,29 @@ namespace Blazor.Pages
[Inject]
public IWebHostEnvironment WebHostEnvironment { get; set; }
/// <summary>
/// The navigation manager for navigating between pages.
/// </summary>
[Inject]
public NavigationManager NavigationManager { get; set; }
/// <summary>
/// The modal service for displaying modal dialogs
/// </summary>
[CascadingParameter]
public IModalService Modal { get; set; }
/// <summary>
/// The localizer for the List page.
/// </summary>
[Inject]
public IStringLocalizer<List> Localizer { get; set; }
/// <summary>
/// Event handler for reading data in the data grid.
/// </summary>
/// <param name="e">The event arguments.</param>
/// <returns>A task representing the asynchronous operation.</returns>
private async Task OnReadData(DataGridReadDataEventArgs<Item> e)
{
if (e.CancellationToken.IsCancellationRequested)
@ -45,6 +62,10 @@ namespace Blazor.Pages
}
}
/// <summary>
/// Event handler for deleting an item.
/// </summary>
/// <param name="id">The id of the item to delete.</param>
private async void OnDelete(int id)
{
var parameters = new ModalParameters();

Loading…
Cancel
Save