Compare commits
19 Commits
Author | SHA1 | Date |
---|---|---|
|
4f67b0bf0e | 1 year ago |
|
696a0bec00 | 1 year ago |
|
a09eab26ae | 1 year ago |
|
50da11c8c1 | 1 year ago |
|
f414f8c385 | 1 year ago |
|
095eecaaef | 1 year ago |
|
6323707179 | 1 year ago |
|
e13ce59447 | 1 year ago |
|
8bbc76c255 | 1 year ago |
|
276d9668f2 | 1 year ago |
|
4398571200 | 1 year ago |
|
5786ee0e54 | 1 year ago |
|
78954ae3d3 | 1 year ago |
|
6ca57fb022 | 1 year ago |
|
6163f7d4cf | 1 year ago |
|
7fc82cf752 | 1 year ago |
|
0221c0da46 | 1 year ago |
|
e26be60eb5 | 1 year ago |
|
cedecba357 | 1 year ago |
File diff suppressed because one or more lines are too long
@ -0,0 +1,35 @@
|
||||
using adminBlazor.Models;
|
||||
|
||||
namespace adminBlazor.Factories;
|
||||
|
||||
public class TranslationFactory
|
||||
{
|
||||
public static Translation Create(TranslationModel model)
|
||||
{
|
||||
return new Translation
|
||||
{
|
||||
Id = model.Id,
|
||||
FirstWord = model.FirstWord,
|
||||
SecondWord = model.SecondWord
|
||||
};
|
||||
}
|
||||
|
||||
public static TranslationModel ToModel(Translation translation)
|
||||
{
|
||||
return new TranslationModel
|
||||
{
|
||||
Id = translation.Id,
|
||||
FirstWord = translation.FirstWord,
|
||||
SecondWord = translation.SecondWord
|
||||
};
|
||||
}
|
||||
|
||||
public static void Update(Translation item, TranslationModel model)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(model.FirstWord))
|
||||
item.FirstWord = model.FirstWord;
|
||||
|
||||
if (!string.IsNullOrEmpty(model.SecondWord))
|
||||
item.SecondWord = model.SecondWord;
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
@page "/add"
|
||||
@page "/addUser"
|
||||
@attribute [Authorize(Roles = "admin")]
|
||||
@using adminBlazor.Models
|
||||
<h3>Add</h3>
|
||||
|
||||
<EditForm Model="@user" OnValidSubmit="@HandleValidSubmit">
|
@ -0,0 +1,44 @@
|
||||
@page "/addVoc"
|
||||
@attribute [Authorize(Roles = "teacher")]
|
||||
@using adminBlazor.Models
|
||||
@using Blazorise.Extensions
|
||||
<h3>Add Vocabulary List</h3>
|
||||
|
||||
<EditForm Model="@voc" OnValidSubmit="@HandleValidSubmit">
|
||||
<DataAnnotationsValidator />
|
||||
<ValidationSummary />
|
||||
|
||||
<p>
|
||||
<label for="name">
|
||||
Name:
|
||||
<InputText id="name" @bind-Value="voc.Name" />
|
||||
<ValidationMessage For="@(() => voc.Name)"/>
|
||||
</label>
|
||||
</p>
|
||||
<h4>Words:</h4>
|
||||
@if (voc.Translations.IsNullOrEmpty() == false)
|
||||
{
|
||||
foreach (var word in voc.Translations)
|
||||
{
|
||||
{
|
||||
<div class="word-container">
|
||||
<label>
|
||||
First Word:
|
||||
<InputText @bind-Value="word.FirstWord"/>
|
||||
</label>
|
||||
<label>
|
||||
Second Word:
|
||||
<InputText @bind-Value="word.SecondWord"/>
|
||||
</label>
|
||||
</div>
|
||||
<button type="button" @onclick="() => RemoveWord(word)">Remove Word</button>
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
<p>No words</p>
|
||||
}
|
||||
<button type="button" @onclick="AddWord">Add Word</button>
|
||||
<button type="submit">Submit</button>
|
||||
</EditForm>
|
@ -1,29 +1,55 @@
|
||||
@page "/editVoc/{Id:int}"
|
||||
@attribute [Authorize(Roles = "teacher")]
|
||||
@using adminBlazor.Models
|
||||
@using Blazorise.Extensions
|
||||
|
||||
|
||||
<h3>Edit</h3>
|
||||
<h4>Voc id : @Id</h4>
|
||||
<EditForm Model="@voc" OnValidSubmit="@HandleValidSubmit">
|
||||
<DataAnnotationsValidator />
|
||||
<ValidationSummary />
|
||||
@if (voc != null)
|
||||
{
|
||||
<EditForm Model="@voc" OnValidSubmit="@HandleValidSubmit">
|
||||
<DataAnnotationsValidator />
|
||||
<ValidationSummary />
|
||||
|
||||
<p>
|
||||
<label for="name">
|
||||
Name:
|
||||
<InputText id="name" @bind-Value="voc.Name" />
|
||||
<ValidationMessage For="@(() => voc.Name)" />
|
||||
</label>
|
||||
|
||||
<p>
|
||||
<label for="name">
|
||||
Name:
|
||||
<InputText id="name" @bind-Value="voc.Name" />
|
||||
<ValidationMessage For="@(() => voc.Name)" />
|
||||
</label>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<label for="image">
|
||||
Image:
|
||||
<InputText id="image" @bind-Value="voc.Image" />
|
||||
<ValidationMessage For="@(() => voc.Image)" />
|
||||
</label>
|
||||
</p>
|
||||
|
||||
<button type="submit">Submit</button>
|
||||
</EditForm>
|
||||
</p>
|
||||
|
||||
<h4>Words:</h4>
|
||||
@if (voc.Translations.IsNullOrEmpty() == false)
|
||||
{
|
||||
foreach (var word in voc.Translations)
|
||||
{
|
||||
{
|
||||
<div class="word-container">
|
||||
<label>
|
||||
First Word:
|
||||
<InputText @bind-Value="word.FirstWord"/>
|
||||
</label>
|
||||
<label>
|
||||
Second Word:
|
||||
<InputText @bind-Value="word.SecondWord"/>
|
||||
</label>
|
||||
</div>
|
||||
<button type="button" @onclick="() => RemoveWord(word)">Remove Word</button>
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
<p>No words</p>
|
||||
}
|
||||
<button type="button" @onclick="AddWord">Add Word</button>
|
||||
<button type="submit">Submit</button>
|
||||
</EditForm>
|
||||
}
|
||||
else
|
||||
{
|
||||
<p>Loading...</p>
|
||||
}
|
After Width: | Height: | Size: 156 KiB |
Loading…
Reference in new issue