@page "/Settings"
@using Common.Dtos.Company
@using HushianWebApp.Components
@using HushianWebApp.Service
@using HushianWebApp.Services
@inject ILocalStorageService localStorageService;
@inject NavigationManager navigationManager;
@inject CompanyService companyService;
@if (ALLOWcompanyinfo)
{
}
@code {
[Inject] protected ToastService ToastService { get; set; } = default!;
bool ALLOWcompanyinfo = true;
public bool loading { get; set; } = false;
public ReadANDUpdate_CompanyDto dto { get; set; }
= new();
int CompanyID = 0;
protected override async Task OnInitializedAsync()
{
if (await localStorageService.GetItem("Role") != "Company")
navigationManager.NavigateTo("/NotFound");
CompanyID= await localStorageService.GetItem("C/CompanyId");
dto = await companyService.GetCompany(CompanyID);
await base.OnInitializedAsync();
}
private async Task OnFileChange(InputFileChangeEventArgs e)
{
var file = e.File;
using (var memoryStream = new MemoryStream())
{
await file.OpenReadStream().CopyToAsync(memoryStream);
dto.logo = memoryStream.ToArray();
}
}
private string GetImageSource()
{
if (dto.logo != null)
{
return $"data:image/jpeg;base64,{Convert.ToBase64String(dto.logo)}";
}
return string.Empty;
}
async Task updateItem()
{
if (await companyService.UpdateCompany(dto))
ToastService.Notify(new ToastMessage(ToastType.Success, "تغییر اطلاعات شرکت با موفقیت انجام شد"));
}
}