186 lines
8.2 KiB
Plaintext
186 lines
8.2 KiB
Plaintext
@page "/user/serviceprovider/{id}"
|
|
@using AyCode.Core
|
|
@using AyCode.Services.Loggers
|
|
@using BlazorAnimation
|
|
@using TIAM.Entities.ServiceProviders
|
|
@using TIAM.Resources
|
|
@using TIAM.Services
|
|
@using TIAMSharedUI.Pages.User.SysAdmins
|
|
@using TIAMSharedUI.Shared
|
|
@using TIAMSharedUI.Shared.Components.Grids
|
|
@using TIAMWebApp.Shared.Application.Interfaces
|
|
@using TIAMWebApp.Shared.Application.Services
|
|
@using TIAMWebApp.Shared.Application.Utility
|
|
@using TIAMSharedUI.Shared.Components.BaseComponents
|
|
@inherits BasePageComponent
|
|
@layout AdminLayout
|
|
@inject NavigationManager navigationManager
|
|
@inject IEnumerable<IAcLogWriterClientBase> LogWriters
|
|
@inject IStringLocalizer<TIAMResources> localizer
|
|
@inject IServiceProviderDataService serviceProviderDataService
|
|
@inject IUserDataService userDataService
|
|
@inject ISessionService sessionService
|
|
@inject AdminSignalRClient AdminSignalRClient;
|
|
<PageTitle>Admin - Companies</PageTitle>
|
|
|
|
<div class="text-center m-5">
|
|
<h1>@CompanyName</h1>
|
|
<h2 style="font-size:small">Manage your service provider details</h2>
|
|
</div>
|
|
|
|
<div class="container-fluid">
|
|
<div class="row">
|
|
<div class=" col-12">
|
|
<Animation Effect="@Effect.FadeIn" Speed="@Speed.Fast" Delay="@TimeSpan.FromMilliseconds(500)">
|
|
<div class="card">
|
|
<DxTabs>
|
|
<DxTabPage Text="Details">
|
|
@if (resultCompany != null)
|
|
{
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h2>@(isEditMode ? "Edit Service Provider" : "Service Provider Details")</h2>
|
|
</div>
|
|
<div class="card-body">
|
|
@if (isEditMode)
|
|
{
|
|
<EditForm Model="@resultCompany">
|
|
<DataAnnotationsValidator />
|
|
<div class="form-group">
|
|
<label for="name">Name</label>
|
|
<InputText id="name" class="form-control" @bind-Value="resultCompany.Name" />
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="email">Public Email</label>
|
|
<InputText id="email" class="form-control" @bind-Value="resultCompany.Profile.EmailAddress" />
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="publicName">Public name</label>
|
|
<InputText id="publicName" class="form-control" @bind-Value="resultCompany.Profile.Name" />
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="profileDescription">Public description</label>
|
|
<InputText id="profileDescription" class="form-control" @bind-Value="resultCompany.Profile.Description" />
|
|
</div>
|
|
|
|
<button type="button" class="btn btn-primary" @onclick="Save">Save</button>
|
|
<button type="button" class="btn btn-secondary" @onclick="() => isEditMode = false">Cancel</button>
|
|
</EditForm>
|
|
}
|
|
else
|
|
{
|
|
<div class="p-5">
|
|
<dl class="row">
|
|
<dt class="col-sm-3">Name</dt>
|
|
<dd class="col-sm-9">@resultCompany.Name</dd>
|
|
|
|
<dt class="col-sm-3">Affiliate ID</dt>
|
|
<dd class="col-sm-9">@resultCompany.AffiliateId</dd>
|
|
|
|
<dt class="col-sm-3">Created</dt>
|
|
<dd class="col-sm-9">@resultCompany.Created</dd>
|
|
|
|
<dt class="col-sm-3">Modified</dt>
|
|
<dd class="col-sm-9">@resultCompany.Modified</dd>
|
|
</dl>
|
|
</div>
|
|
<div class="p-5">
|
|
<dl class="row">
|
|
<dt class="col-sm-3">Name</dt>
|
|
<dd class="col-sm-9">@resultCompany.Profile.Name</dd>
|
|
|
|
<dt class="col-sm-3">Public email address</dt>
|
|
<dd class="col-sm-9">@resultCompany.Profile.EmailAddress</dd>
|
|
|
|
<dt class="col-sm-3">Description</dt>
|
|
<dd class="col-sm-9">@resultCompany.Profile.Description</dd>
|
|
|
|
<dt class="col-sm-3">Address</dt>
|
|
<dd class="col-sm-9">@resultCompany.Profile.Address.AddressText</dd>
|
|
</dl>
|
|
</div>
|
|
<button type="button" class="btn btn-primary" @onclick="Edit">Edit</button>
|
|
}
|
|
</div>
|
|
</div>
|
|
}
|
|
else
|
|
{
|
|
<p>Loading...</p>
|
|
}
|
|
</DxTabPage>
|
|
<DxTabPage Text="Profile">
|
|
<ProfileGridComponent ParentData="resultCompany" />
|
|
</DxTabPage>
|
|
<DxTabPage Text="Address">
|
|
<AddressDetailGridComponent ParentData="resultCompany.Profile" />
|
|
</DxTabPage>
|
|
<DxTabPage Text="Services">
|
|
<ProductDetailGridComponent GetAllTag="SignalRTags.GetProductsByOwnerId" ShowManageButtons="true" ContextId="@resultCompany.Id" ParentData="@resultCompany" />
|
|
</DxTabPage>
|
|
</DxTabs>
|
|
</div>
|
|
</Animation>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
@code {
|
|
|
|
|
|
|
|
|
|
|
|
[Parameter]
|
|
public string Id { get; set; }
|
|
|
|
public string ProfileUrl => $"/images/serviceprovider/{Id}.png";
|
|
|
|
private LoggerClient<ServiceProvider> _logger;
|
|
|
|
private Company resultCompany;
|
|
|
|
private string CompanyName;
|
|
|
|
private bool isEditMode = false;
|
|
|
|
|
|
private void Edit()
|
|
{
|
|
isEditMode = true;
|
|
}
|
|
|
|
private async Task Save()
|
|
{
|
|
|
|
_logger.Debug($"Saving {resultCompany.Name}");
|
|
var result = await serviceProviderDataService.UpdateServiceProviderAsync(resultCompany);
|
|
isEditMode = false;
|
|
navigationManager.NavigateTo($"/user/serviceprovider/{resultCompany.Id}");
|
|
}
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
base.OnInitialized();
|
|
_logger = new LoggerClient<ServiceProvider>(LogWriters.ToArray());
|
|
}
|
|
|
|
protected override async Task OnParametersSetAsync()
|
|
{
|
|
if (string.IsNullOrEmpty(Id))
|
|
{
|
|
navigationManager.NavigateTo("/user/properties");
|
|
}
|
|
else
|
|
{
|
|
|
|
resultCompany = await serviceProviderDataService.GetServiceProviderByIdAsync(Guid.Parse(Id));
|
|
CompanyName = resultCompany.Name;
|
|
}
|
|
base.OnParametersSet();
|
|
}
|
|
|
|
}
|