@using Common.Dtos.User
@using Hushian.Application.Dtos
@using HushianWebApp.Service
@using HushianWebApp.Services
@inject UserService userService;
@code {
[Parameter] public EditUserFromUserDto model { get; set; }
[Parameter] public EventCallback OnMultipleOfThree { get; set; }
public bool loading { get; set; } = false;
}
@functions{
async Task NewItem()
{
if (!string.IsNullOrEmpty(model.FullName))
{
if (string.IsNullOrEmpty(model.Email)) model.Email = $"{model.UserName}@hushian.ir";
loading = true;
if (await userService.ExperEditingFromManager(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;
}
}