Company page
This commit is contained in:
parent
d1a8f706d4
commit
7a6fe38b9f
|
|
@ -46,7 +46,7 @@ namespace TIAM.Database.Test
|
||||||
//_userDal = new UserDal(_mockContext.Object);
|
//_userDal = new UserDal(_mockContext.Object);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
//[TestMethod]
|
||||||
public async Task ConvertOldPassword()
|
public async Task ConvertOldPassword()
|
||||||
{
|
{
|
||||||
//var loginService = new LoginService(Dal, AppSettingsConfiguration);
|
//var loginService = new LoginService(Dal, AppSettingsConfiguration);
|
||||||
|
|
|
||||||
|
|
@ -346,7 +346,29 @@ namespace TIAM.Database.DataLayers.Admins
|
||||||
//}
|
//}
|
||||||
|
|
||||||
//14. (IserviceProviderDataService) Update service provider
|
//14. (IserviceProviderDataService) Update service provider
|
||||||
public Task<bool> UpdateCompanyAsync(Company company) => TransactionAsync(ctx => ctx.UpdateCompany(company));
|
public Task<bool> UpdateCompanyAsync(Company company)
|
||||||
|
{
|
||||||
|
var result = NewUpdateCompanyAsync(company);
|
||||||
|
if (result.Result != null || (result.Result).Id != Guid.Empty)
|
||||||
|
{
|
||||||
|
return Task.FromResult(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Task.FromResult(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<Company?> NewUpdateCompanyAsync(Company company) => UpdateSafeAsync(company, (ctx, safeCompany) => ctx.UpdateCompany(safeCompany));
|
||||||
|
|
||||||
|
public Task<bool> UpdateCompanyAsync(Company company, Profile profile)
|
||||||
|
=> TransactionAsync(ctx =>
|
||||||
|
{
|
||||||
|
ctx.UpdateProfile(profile);
|
||||||
|
ctx.SaveChanges();
|
||||||
|
|
||||||
|
return ctx.UpdateCompany(company);
|
||||||
|
});
|
||||||
|
|
||||||
//13. (IserviceProviderDataService) delete service provider
|
//13. (IserviceProviderDataService) delete service provider
|
||||||
public Task<bool> RemoveCompanyAsync(Guid companyId) => TransactionAsync(ctx => ctx.RemoveProductsByCompanyId(companyId) && ctx.RemoveCompany(companyId));
|
public Task<bool> RemoveCompanyAsync(Guid companyId) => TransactionAsync(ctx => ctx.RemoveProductsByCompanyId(companyId) && ctx.RemoveCompany(companyId));
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|
||||||
<HotelComponent Id="@id"></HotelComponent>
|
<HotelComponent Id="@Guid.Parse(id)"></HotelComponent>
|
||||||
|
|
||||||
<!-- Stats admin-->
|
<!-- Stats admin-->
|
||||||
<hr />
|
<hr />
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
[Parameter] public Guid id { get; set; }
|
[Parameter] public string id { get; set; }
|
||||||
bool isUserLoggedIn;
|
bool isUserLoggedIn;
|
||||||
int userType = 0;
|
int userType = 0;
|
||||||
|
|
||||||
|
|
@ -35,7 +35,7 @@
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var check = SessionService.User.UserModelDto.UserProductMappings.Any(x => x.ProductId == id);
|
var check = SessionService.User.UserModelDto.UserProductMappings.Any(x => x.ProductId == Guid.Parse(id));
|
||||||
if (!check)
|
if (!check)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,183 @@
|
||||||
|
@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
|
||||||
|
@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.Pulse" 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" 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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -50,18 +50,20 @@
|
||||||
EditMode="GridEditMode.EditRow">
|
EditMode="GridEditMode.EditRow">
|
||||||
<Columns>
|
<Columns>
|
||||||
<DxGridCommandColumn Width="160px" />
|
<DxGridCommandColumn Width="160px" />
|
||||||
<DxGridDataColumn FieldName="Id" MinWidth="80">
|
<DxGridDataColumn FieldName="Id" Visible="false" MinWidth="130" />
|
||||||
|
<DxGridDataColumn FieldName="Name" MinWidth="80" />
|
||||||
|
<DxGridDataColumn FieldName="AffiliateId" MinWidth="80" />
|
||||||
|
<DxGridDataColumn FieldName="Id" Width="130">
|
||||||
<CellDisplayTemplate>
|
<CellDisplayTemplate>
|
||||||
<a class="d-block text-left" href="user/serviceprovider/@context.Value.ToString()">@context.Value</a>
|
<a class="btn btn-primary" href="user/serviceprovider/@context.Value.ToString()">Manage</a>
|
||||||
</CellDisplayTemplate>
|
</CellDisplayTemplate>
|
||||||
</DxGridDataColumn>
|
</DxGridDataColumn>
|
||||||
<DxGridDataColumn Caption="Address" FieldName="Profile.Address.AddressText" MinWidth="80" />
|
<DxGridDataColumn Caption="Address" FieldName="Profile.Address.AddressText" Width="280" />
|
||||||
<DxGridDataColumn FieldName="Name" MinWidth="80" />
|
|
||||||
|
|
||||||
</Columns>
|
</Columns>
|
||||||
<DetailRowTemplate>
|
<DetailRowTemplate>
|
||||||
@{
|
@{
|
||||||
<p>@(((Company)context.DataItem).Profile.Address.AddressText)</p>
|
<p>Address: @(((Company)context.DataItem).Profile.Address.AddressText)</p>
|
||||||
}
|
}
|
||||||
</DetailRowTemplate>
|
</DetailRowTemplate>
|
||||||
</CompanyGrid>
|
</CompanyGrid>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
@page "/user/serviceprovider/{id}"
|
@page "/user/serviceproviderold/{id}"
|
||||||
@using AyCode.Core
|
@using AyCode.Core
|
||||||
@using AyCode.Services.Loggers
|
@using AyCode.Services.Loggers
|
||||||
@using TIAM.Entities.ServiceProviders
|
@using TIAM.Entities.ServiceProviders
|
||||||
|
|
@ -21,14 +21,14 @@
|
||||||
<PageTitle>Admin - Companies</PageTitle>
|
<PageTitle>Admin - Companies</PageTitle>
|
||||||
|
|
||||||
<div class="text-center m-5">
|
<div class="text-center m-5">
|
||||||
<h1>Company</h1>
|
<h1>@CompanyName</h1>
|
||||||
<h2 style="font-size:small">Manage your service provider details</h2>
|
<h2 style="font-size:small">Manage your service provider details</h2>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="w-100 ch-220">
|
<div class="w-100 ch-220">
|
||||||
<CompanyByIdDetailGrid @ref="_gridCompany"
|
<CompanyByIdDetailGrid @ref="_gridCompany"
|
||||||
Context="myContext"
|
Context="myContext"
|
||||||
ContextIds="@CompanyId"
|
ContextIds="@CompanyId"
|
||||||
Logger="_logger"
|
Logger="_logger"
|
||||||
SignalRClient="AdminSignalRClient"
|
SignalRClient="AdminSignalRClient"
|
||||||
|
|
@ -101,6 +101,8 @@
|
||||||
|
|
||||||
private LoggerClient<ServiceProvider> _logger;
|
private LoggerClient<ServiceProvider> _logger;
|
||||||
|
|
||||||
|
private string CompanyName;
|
||||||
|
|
||||||
protected override void OnInitialized()
|
protected override void OnInitialized()
|
||||||
{
|
{
|
||||||
base.OnInitialized();
|
base.OnInitialized();
|
||||||
|
|
@ -116,16 +118,20 @@
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CompanyId[0] = Guid.Parse(Id);
|
CompanyId[0] = Guid.Parse(Id);
|
||||||
|
var result = serviceProviderDataService.GetServiceProviderByIdAsync(Guid.Parse(Id));
|
||||||
|
|
||||||
}
|
}
|
||||||
base.OnParametersSet();
|
base.OnParametersSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Grid_CustomizeElement(GridCustomizeElementEventArgs e)
|
void Grid_CustomizeElement(GridCustomizeElementEventArgs e)
|
||||||
{
|
{
|
||||||
//TODO mark non active partners
|
//TODO mark non active partners
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Grid_CustomizeEditModel(GridCustomizeEditModelEventArgs e)
|
void Grid_CustomizeEditModel(GridCustomizeEditModelEventArgs e)
|
||||||
{
|
{
|
||||||
if (!e.IsNew)
|
if (!e.IsNew)
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@
|
||||||
GetAllMessageTag="GetAllTag"
|
GetAllMessageTag="GetAllTag"
|
||||||
Logger="_logger"
|
Logger="_logger"
|
||||||
SignalRClient="AdminSignalRClient"
|
SignalRClient="AdminSignalRClient"
|
||||||
|
CustomizeEditModel="CustomizeEditModel"
|
||||||
OnGridEditModelSaving="DataItemSaving"
|
OnGridEditModelSaving="DataItemSaving"
|
||||||
OnGridItemDeleting="DataItemDeleting"
|
OnGridItemDeleting="DataItemDeleting"
|
||||||
OnGridItemChanged="DataItemChanged"
|
OnGridItemChanged="DataItemChanged"
|
||||||
|
|
@ -73,7 +74,10 @@
|
||||||
<DxFormLayoutItem Caption=@Localizer.GetString(ResourceKeys.Price) ColSpanMd="4">
|
<DxFormLayoutItem Caption=@Localizer.GetString(ResourceKeys.Price) ColSpanMd="4">
|
||||||
@editFormContext.GetEditor("Price")
|
@editFormContext.GetEditor("Price")
|
||||||
</DxFormLayoutItem>
|
</DxFormLayoutItem>
|
||||||
<DxFormLayoutItem Caption=@Localizer.GetString(ResourceKeys.ProductDescription) ColSpanMd="4">
|
<DxFormLayoutItem Caption="Company Id" ColSpanMd="4">
|
||||||
|
<p>@(((Product)editFormContext.EditModel).ServiceProviderId)</p>
|
||||||
|
</DxFormLayoutItem>
|
||||||
|
<DxFormLayoutItem Caption=@Localizer.GetString(ResourceKeys.ProductDescription) ColSpanMd="12">
|
||||||
@editFormContext.GetEditor("Description")
|
@editFormContext.GetEditor("Description")
|
||||||
</DxFormLayoutItem>
|
</DxFormLayoutItem>
|
||||||
|
|
||||||
|
|
@ -135,7 +139,7 @@
|
||||||
if (e.IsNew)
|
if (e.IsNew)
|
||||||
{
|
{
|
||||||
_logger.Debug($"DataItemSaving");
|
_logger.Debug($"DataItemSaving");
|
||||||
|
// product.ServiceProviderId = ((Company)ParentData).Id;
|
||||||
// var profileId = Guid.NewGuid();
|
// var profileId = Guid.NewGuid();
|
||||||
// product.Profile = new Profile(profileId, product.Name);
|
// product.Profile = new Profile(profileId, product.Name);
|
||||||
// product.ProfileId = profileId;
|
// product.ProfileId = profileId;
|
||||||
|
|
@ -152,7 +156,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.Debug($"Saving: {product.Name}, {product.ServiceProviderId}");
|
_logger.Debug($"Saving: {product.Name}, {product.ServiceProviderId}");
|
||||||
|
|
||||||
//var result = serviceProviderDataService.CreateProductAsync((Product)e.EditModel);
|
//var result = serviceProviderDataService.CreateProductAsync((Product)e.EditModel);
|
||||||
//_logger.Debug($"saved product: {product.ServiceProviderId}");
|
//_logger.Debug($"saved product: {product.ServiceProviderId}");
|
||||||
}
|
}
|
||||||
|
|
@ -172,7 +176,8 @@
|
||||||
newProduct.ServiceProviderId = (Guid)ContextId!;
|
newProduct.ServiceProviderId = (Guid)ContextId!;
|
||||||
newProduct.Price = 0;
|
newProduct.Price = 0;
|
||||||
newProduct.ProductType = TIAM.Core.Enums.ProductType.Hotel;
|
newProduct.ProductType = TIAM.Core.Enums.ProductType.Hotel;
|
||||||
newProduct.Description = "Type a description";
|
newProduct.Description = "Type a description";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -22,5 +22,5 @@ public class CompanyDetailGrid : CompanyGrid
|
||||||
if (isFirst)
|
if (isFirst)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue