@using Common.Dtos.Group
@using HushianWebApp.Service
@inject GroupService groupService;
@code {
public ADD_GroupDto model { get; set; } = new();
[Parameter] public EventCallback OnMultipleOfThree { get; set; }
public bool loading { get; set; } = false;
}
@functions {
async Task NewItem()
{
if (!string.IsNullOrEmpty(model.Name))
{
loading = true;
if (await groupService.AddGroup(model))
{
loading = false;
await OnMultipleOfThree.InvokeAsync();
}
loading = false;
}
}
private async Task OnFileChange(InputFileChangeEventArgs e)
{
var file = e.File;
using (var memoryStream = new MemoryStream())
{
await file.OpenReadStream().CopyToAsync(memoryStream);
model.img = memoryStream.ToArray();
}
}
private string GetImageSource()
{
if (model.img != null)
{
return $"data:image/jpeg;base64,{Convert.ToBase64String(model.img)}";
}
return string.Empty;
}
}