📝 Update docs
continuous-integration/drone/push Build is passing Details

master
Julien Riboulet 2 years ago
parent aa4cadf5d6
commit 055c868ce9

@ -12,45 +12,18 @@ Open the `Pages/Add.razor.cs` file and add the highlighted lines:
```csharp title="Pages/Add.razor.cs" ```csharp title="Pages/Add.razor.cs"
public partial class Add public partial class Add
{ {
[Inject] ...
public ILocalStorageService LocalStorage { get; set; }
// highlight-start // highlight-start
[Inject] [Inject]
public NavigationManager NavigationManager { get; set; } public NavigationManager NavigationManager { get; set; }
// highlight-end // highlight-end
/// <summary> ...
/// The default roles.
/// </summary>
private List<string> roles = new List<string>() { "admin", "writter", "reader", "member" };
/// <summary>
/// The current data model
/// </summary>
private DataModel dataModel = new()
{
DateOfBirth = DateTime.Now,
Roles = new List<string>()
};
private async void HandleValidSubmit() private async void HandleValidSubmit()
{ {
// Get the current data ...
var currentData = await LocalStorage.GetItemAsync<List<Data>>("data");
// Simulate the Id
dataModel.Id = currentData.Max(s => s.Id) + 1;
// Add the item to the current data
currentData.Add(new Data
{
LastName = dataModel.LastName,
DateOfBirth = dataModel.DateOfBirth,
FirstName = dataModel.FirstName,
Id = dataModel.Id,
Roles = dataModel.Roles
});
// Save the data // Save the data
await LocalStorage.SetItemAsync("data", currentData); await LocalStorage.SetItemAsync("data", currentData);
@ -58,24 +31,6 @@ public partial class Add
// highlight-next-line // highlight-next-line
NavigationManager.NavigateTo("list"); NavigationManager.NavigateTo("list");
} }
private void OnRoleChange(string item, object checkedValue)
{
if ((bool)checkedValue)
{
if (!dataModel.Roles.Contains(item))
{
dataModel.Roles.Add(item);
}
return;
}
if (dataModel.Roles.Contains(item))
{
dataModel.Roles.Remove(item);
}
}
} }
``` ```

@ -154,8 +154,6 @@ The following code:
``` ```
```csharp title="Config.razor.cs" ```csharp title="Config.razor.cs"
private PositionOptions positionOptions;
public partial class Config public partial class Config
{ {
[Inject] [Inject]

@ -12,45 +12,18 @@ Ouvrez le fichier `Pages/Add.razor.cs` et ajouter les lignes en surbrillances :
```csharp title="Pages/Add.razor.cs" ```csharp title="Pages/Add.razor.cs"
public partial class Add public partial class Add
{ {
[Inject] ...
public ILocalStorageService LocalStorage { get; set; }
// highlight-start // highlight-start
[Inject] [Inject]
public NavigationManager NavigationManager { get; set; } public NavigationManager NavigationManager { get; set; }
// highlight-end // highlight-end
/// <summary> ...
/// The default roles.
/// </summary>
private List<string> roles = new List<string>() { "admin", "writter", "reader", "member" };
/// <summary>
/// The current data model
/// </summary>
private DataModel dataModel = new()
{
DateOfBirth = DateTime.Now,
Roles = new List<string>()
};
private async void HandleValidSubmit() private async void HandleValidSubmit()
{ {
// Get the current data ...
var currentData = await LocalStorage.GetItemAsync<List<Data>>("data");
// Simulate the Id
dataModel.Id = currentData.Max(s => s.Id) + 1;
// Add the item to the current data
currentData.Add(new Data
{
LastName = dataModel.LastName,
DateOfBirth = dataModel.DateOfBirth,
FirstName = dataModel.FirstName,
Id = dataModel.Id,
Roles = dataModel.Roles
});
// Save the data // Save the data
await LocalStorage.SetItemAsync("data", currentData); await LocalStorage.SetItemAsync("data", currentData);
@ -58,24 +31,6 @@ public partial class Add
// highlight-next-line // highlight-next-line
NavigationManager.NavigateTo("list"); NavigationManager.NavigateTo("list");
} }
private void OnRoleChange(string item, object checkedValue)
{
if ((bool)checkedValue)
{
if (!dataModel.Roles.Contains(item))
{
dataModel.Roles.Add(item);
}
return;
}
if (dataModel.Roles.Contains(item))
{
dataModel.Roles.Remove(item);
}
}
} }
``` ```

@ -158,8 +158,6 @@ Le code suivant :
``` ```
```csharp title="Config.razor.cs" ```csharp title="Config.razor.cs"
private PositionOptions positionOptions;
public partial class Config public partial class Config
{ {
[Inject] [Inject]

Loading…
Cancel
Save