modif prcq j'avais rien compris a la configuration

blazor
Patrick BRUGIERE 1 year ago
parent 81d372e21d
commit 03c4df537e

@ -0,0 +1,13 @@
using System.Data;
namespace adminBlazor.Models
{
public class CreatorOptions
{
public const string Creators = "Creators";
public List<string> Name { get; set; }
}
}

@ -1,30 +0,0 @@
using System.Data;
namespace adminBlazor.Models
{
public class UserOptions
{
public const string User = "User";
public int Id { get; set; }
public string Name { get; set; }
public string Surname { get; set; }
public string Nickname { get; set; }
public bool ExtraTime { get; set; }
public int Group { get; set; }
public List<string> Roles { get; set; }
public UserOptions()
{
// Constructeur sans paramètre public
Id = 1;
Name = "DefaultName";
Surname = "DefaultSurname";
Nickname = "DefaultNickname";
ExtraTime = false;
Group = 0;
Roles = new List<string>();
}
}
}

@ -2,15 +2,25 @@
<h3>Config</h3>
@if (userOptions != null)
@if (creatorOptions != null)
{
<div>
<div>Title: @userOptions.id</div>
<div>Name: @userOptions.name</div>
<div>Surname: @userOptions.Surname</div>
<div>Nickname: @userOptions.Nickname</div>
<div>ExtraTime: @userOptions.ExtraTime</div>
<div>Group: @userOptions.Group</div>
<div>Roles: @string.Join(", ", userOptions.Roles)</div>
<div>Logging:LogLevel:Default: @Configuration["Logging:LogLevel:Default"]</div>
<div>Logging:LogLevel:Default: @Configuration["Logging:LogLevel:Microsoft.AspNetCore"]</div>
<h4>Noms des créateurs</h4>
@if (creatorOptions.Name != null)
{
@foreach (var creator in creatorOptions.Name)
{
<div>@creator</div>
}
}
else
{
<div>No creators found</div>
}
</div>
}

@ -9,14 +9,19 @@ namespace adminBlazor.Pages
public IConfiguration Configuration { get; set; }
private UserOptions userOptions;
private CreatorOptions creatorOptions;
protected override void OnInitialized()
{
base.OnInitialized();
userOptions = new UserOptions();
Configuration.GetSection(UserOptions.User).Bind(userOptions);
creatorOptions = new CreatorOptions();
Configuration.GetSection(CreatorOptions.Creators).Bind(creatorOptions);
if (creatorOptions.Name == null)
{
return;
}
}
}

@ -5,6 +5,7 @@
<a href="/list">@Localizer["Users"]</a>
<a href="/account">@Localizer["My account"]</a>
<a href="/voc">@Localizer["Vocabulary Lists"]</a>
<a href="/config">@Localizer["Config"]</a>
</div>

@ -1,4 +1,12 @@
{
"Creators": {
"Name": [
"Patrick Brugière",
"Anthony Richard",
"Antoine Jourdain",
"Lucie Goigoux"
]
},
"Logging": {
"LogLevel": {
"Default": "Information",
@ -6,5 +14,6 @@
}
},
"AllowedHosts": "*"
}

Loading…
Cancel
Save