-
-
Notifications
You must be signed in to change notification settings - Fork 93
Expand file tree
/
Copy pathAddTalkEntryDialog.razor
More file actions
58 lines (49 loc) · 2.02 KB
/
Copy pathAddTalkEntryDialog.razor
File metadata and controls
58 lines (49 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
@using LinkDotNet.Blog.Domain
<ModalDialog @ref="Dialog" Title="Add Talk">
<EditForm Model="model" OnValidSubmit="CreateTalk">
<DataAnnotationsValidator />
<ValidationSummary />
<div class="mb-3">
<label for="talk-title" class="form-label">Presentation title</label>
<InputText class="form-control" id="talk-title" @bind-Value="model.PresentationTitle" />
</div>
<div class="mb-3">
<label for="talk-place" class="form-label">Presentation place</label>
<InputText class="form-control" id="talk-place" @bind-Value="model.Place" />
<small class="form-text text-secondary">
The place / event where you held the presentation / talk.
</small>
</div>
<div class="mb-3">
<label for="talk-date" class="form-label">Date</label>
<InputDate class="form-control" id="talk-date" @bind-Value="model.PublishedDate" />
</div>
<div class="mb-3">
<label for="talk-content" class="form-label">Description</label>
<MarkdownTextArea id="talk-content" class="form-control" rows="10"
@bind-Value="@model.Description"></MarkdownTextArea>
</div>
<button id="talk-submit" class="btn btn-primary" type="submit">Submit</button>
</EditForm>
</ModalDialog>
@code {
[Parameter]
public EventCallback<Talk> TalkCreated { get; set; }
private ModalDialog Dialog { get; set; } = default!;
private AddTalkEntryModel model = new();
public void Open()
{
Dialog.Open();
StateHasChanged();
}
private async Task CreateTalk()
{
ArgumentNullException.ThrowIfNull(model.PresentationTitle);
ArgumentNullException.ThrowIfNull(model.Place);
ArgumentNullException.ThrowIfNull(model.Description);
var talk = Talk.Create(model.PresentationTitle, model.Place, model.Description, model.PublishedDate);
await TalkCreated.InvokeAsync(talk);
model = new AddTalkEntryModel();
Dialog.Close();
}
}