@using Start.Shared
@using System.IO
@inject HttpClient Http
@code {
[Parameter]
public EventCallback OnCreated { get; set; }
[Parameter]
public bool IsOpen { get; set; }
[Parameter]
public EventCallback OnClose { get; set; }
private BookmarkContainerDto model = new("");
private bool displayError = false;
protected async void OnSubmit()
{
HttpResponseMessage response = await Http
.PostAsJsonAsync("Bookmarks/CreateBookmarkContainer", model.Title);
Stream stream = response.RequestMessage!.Content!.ReadAsStream();
StreamReader reader = new StreamReader(stream);
Console.WriteLine(reader.ReadToEnd());
BookmarkContainerDto? container = await response
!.Content
!.ReadFromJsonAsync();
if (container == null)
{
this.displayError = true;
}
else
{
await this.OnCreated.InvokeAsync(container);
}
}
protected async void OnDialogClose()
{
this.IsOpen = false;
await this.OnClose.InvokeAsync();
}
}