Merge 2
This commit is contained in:
parent
40c061f8f2
commit
3116489d3d
|
|
@ -187,7 +187,7 @@ namespace TIAM.Database.DataLayers.Admins
|
|||
#endregion Address
|
||||
|
||||
#region Profile
|
||||
public Task<Profile?> GetProfileByIdAsync(Guid addressId) => SessionAsync(ctx => ctx.GetProfileById(addressId));
|
||||
public Task<Profile?> GetProfileByIdAsync(Guid profileId) => SessionAsync(ctx => ctx.GetProfileById(profileId));
|
||||
public Task<bool> UpdateProfileAsync(Profile profile) => TransactionAsync(ctx => ctx.UpdateProfile(profile));
|
||||
//public Task<bool> AddProfileAsync(Profile profile) => TransactionAsync(ctx => ctx.AddProfile(profile)); //Nem Add-olunk önmagában Profile-t! - J.
|
||||
//public Task<bool> RemoveProfileAsync(Guid profileId) => TransactionAsync(ctx => ctx.RemoveProfile(profileId)); //Nem törlünk Profile-t! - J.
|
||||
|
|
@ -233,6 +233,7 @@ namespace TIAM.Database.DataLayers.Admins
|
|||
|
||||
|
||||
public virtual Task<Company?> GetServiceProviderByIdAsync(Guid id) => SessionAsync(ctx => ctx.GetServiceProviderById(id));
|
||||
public virtual Task<List<Company>> GetServiceProvidersByOwnerIdAsync(Guid id) => SessionAsync(ctx => ctx.GetServiceProvidersByOwnerId(id));
|
||||
|
||||
//public Task<UserProductMapping> CreateUserProductMappingAsync(UserProductMapping userProductMapping)
|
||||
//{
|
||||
|
|
@ -252,13 +253,6 @@ namespace TIAM.Database.DataLayers.Admins
|
|||
public Task<bool> RemoveCompanyAsync(Company company) => TransactionAsync(ctx => ctx.RemoveServiceProvider(company));
|
||||
|
||||
|
||||
//17. (IServiceProviderDataService) get service provider by ownerId
|
||||
public Task<List<Company>> GetServiceProvidersByOwnerIdAsync()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region PermissionTypes
|
||||
|
|
|
|||
|
|
@ -36,9 +36,9 @@ public class SignalRTags : AcSignalRTags
|
|||
//public const int AddAddress = 32;
|
||||
//public const int RemoveAddress = 33;
|
||||
|
||||
public const int GetProfile = 35;
|
||||
public const int GetProfileById = 35;
|
||||
//public const int GetProfiles = 36;
|
||||
public const int GetProfilesByContextId = 37;
|
||||
//public const int GetProfileByContextId = 37;
|
||||
public const int UpdateProfile = 38;
|
||||
|
||||
//public const int AddAddress = 39;
|
||||
|
|
@ -55,4 +55,11 @@ public class SignalRTags : AcSignalRTags
|
|||
|
||||
public const int GetMessagesByContextId = 60;
|
||||
public const int GetAllMessages = 61;
|
||||
|
||||
public const int GetProductById = 70;
|
||||
public const int GetProductsByOwnerId = 71; //for now until we can send multiple parameters
|
||||
public const int GetProductsByContextId = 72;
|
||||
public const int UpdateProduct = 73;
|
||||
public const int AddProduct = 74;
|
||||
public const int RemoveProduct = 75;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
@inject IPopulationStructureDataProvider DataProvider
|
||||
@inject ISupplierService SupplierService
|
||||
@inject IUserDataService UserDataService
|
||||
<PageTitle>Transfer</PageTitle>
|
||||
<PageTitle>HotelAdmin</PageTitle>
|
||||
|
||||
<div class="text-center m-5">
|
||||
<h1>Dashboard</h1>
|
||||
|
|
@ -22,7 +22,7 @@
|
|||
<hr />
|
||||
|
||||
|
||||
<div class="row py-3">
|
||||
@* <div class="row py-3">
|
||||
<div class=" col-12 col-xl-3">
|
||||
<div class="card glass card-admin" style="border-radius: 16px;">
|
||||
<div class="card-header py-2 px-4">
|
||||
|
|
@ -177,7 +177,7 @@
|
|||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div> *@
|
||||
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="row py-3">
|
||||
|
||||
<div class=" col-12 col-xl-3">
|
||||
|
|
|
|||
|
|
@ -1,7 +1,23 @@
|
|||
@page "/user/serviceprovider/{id}"
|
||||
@using AyCode.Core
|
||||
@using AyCode.Services.Loggers
|
||||
@using TIAM.Entities.ServiceProviders
|
||||
@using TIAM.Resources
|
||||
@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>Company: @Id</h1>
|
||||
|
|
@ -10,18 +26,78 @@
|
|||
|
||||
<div class="container">
|
||||
<div class="w-100 ch-220">
|
||||
<CompanyGrid @ref="_gridCompany"
|
||||
ContextId="@CompanyId"
|
||||
Logger="_logger"
|
||||
SignalRClient="AdminSignalRClient"
|
||||
|
||||
AutoCollapseDetailRow="false"
|
||||
KeyboardNavigationEnabled="true"
|
||||
CustomizeElement="Grid_CustomizeElement"
|
||||
CustomizeEditModel="Grid_CustomizeEditModel"
|
||||
EditMode="GridEditMode.EditForm"
|
||||
ColumnResizeMode="GridColumnResizeMode.NextColumn"
|
||||
ShowFilterRow="true"
|
||||
KeyFieldName="Id">
|
||||
|
||||
<Columns>
|
||||
<DxGridCommandColumn Width="135" MinWidth="135" FixedPosition="GridColumnFixedPosition.Left" />
|
||||
<DxGridDataColumn FieldName="Id" SortIndex="0" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" DisplayFormat="N" />
|
||||
<DxGridDataColumn FieldName="Name" />
|
||||
|
||||
<DxGridDataColumn FieldName="AffiliateId" DisplayFormat="N" />
|
||||
<DxGridDataColumn FieldName="CommissionPercent" />
|
||||
<DxGridDataColumn FieldName="Created" DisplayFormat="g" Width="140" />
|
||||
<DxGridDataColumn FieldName="Modified" DisplayFormat="g" Width="140" />
|
||||
@* <DxGridDataColumn FieldName="ContactEmail">
|
||||
|
||||
</DxGridDataColumn> *@
|
||||
|
||||
</Columns>
|
||||
@* <DetailRowTemplate>
|
||||
<CompaniesNestedUserProductMapping CurrentCompany="(TIAM.Entities.ServiceProviders.Company)context.DataItem" KeyboardNavigationEnabled="true" />
|
||||
</DetailRowTemplate> *@
|
||||
<DetailRowTemplate>
|
||||
<DxTabs>
|
||||
|
||||
<DxTabPage Text="Profile">
|
||||
<ProfileComponent></ProfileComponent>
|
||||
<ProfileGridComponent ProfileId="((Company)context.DataItem).ProfileId" KeyboardNavigationEnabled="true" />
|
||||
</DxTabPage>
|
||||
<DxTabPage Text="Permissions">
|
||||
<PermissionsComponent></PermissionsComponent>
|
||||
<DxTabPage Text="Products">
|
||||
<ProductDetailGridComponent ContextId="((Company)context.DataItem).Id" KeyboardNavigationEnabled="true" />
|
||||
</DxTabPage>
|
||||
<DxTabPage Text="Services">
|
||||
<Products></Products>
|
||||
<DxTabPage Text="Address">
|
||||
<AddressDetailGridComponent ParentData="((Company)context.DataItem).Profile" KeyboardNavigationEnabled="true" />
|
||||
</DxTabPage>
|
||||
</DxTabs>
|
||||
</DetailRowTemplate>
|
||||
<EditFormTemplate Context="EditFormContext">
|
||||
@{
|
||||
var transfer2 = (Company)EditFormContext.EditModel;
|
||||
}
|
||||
<DxFormLayout CssClass="w-100">
|
||||
<DxFormLayoutItem Caption=@localizer.GetString(ResourceKeys.LastName) ColSpanMd="6" ColSpanLg="6" ColSpanSm="12">
|
||||
@EditFormContext.GetEditor("Name")
|
||||
</DxFormLayoutItem>
|
||||
<DxFormLayoutItem Caption=@localizer.GetString(ResourceKeys.LastName) ColSpanMd="6" ColSpanLg="6" ColSpanSm="12">
|
||||
@EditFormContext.GetEditor("CommissionPercent")
|
||||
</DxFormLayoutItem>
|
||||
</DxFormLayout>
|
||||
</EditFormTemplate>
|
||||
</CompanyGrid>
|
||||
|
||||
<DxTabs>
|
||||
@* <DxTabPage Text="Profile">
|
||||
<ProfileComponent></ProfileComponent>
|
||||
</DxTabPage> *@
|
||||
@* <DxTabPage Text="Profile 2">
|
||||
<ProfileGridComponent ProfileId="((Company)context.DataItem).ProfileId" KeyboardNavigationEnabled="true" />
|
||||
</DxTabPage> *@
|
||||
<DxTabPage Text="Products">
|
||||
<ProductDetailGridComponent ContextId="@CompanyId" KeyboardNavigationEnabled="true" />
|
||||
</DxTabPage>
|
||||
@* <DxTabPage Text="Address">
|
||||
<AddressDetailGridComponent ParentData="((Company)context.DataItem).Profile" KeyboardNavigationEnabled="true" />
|
||||
</DxTabPage> *@
|
||||
</DxTabs>
|
||||
</div>
|
||||
|
||||
|
|
@ -32,12 +108,53 @@
|
|||
[Parameter]
|
||||
public string Id { get; set; }
|
||||
|
||||
private Guid CompanyId;
|
||||
|
||||
private CompanyGrid _gridCompany;
|
||||
|
||||
public string ProfileUrl => $"/images/serviceprovider/{Id}.png";
|
||||
|
||||
private LoggerClient<ServiceProvider> _logger;
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
base.OnInitialized();
|
||||
_logger = new LoggerClient<ServiceProvider>(LogWriters.ToArray());
|
||||
}
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
if (string.IsNullOrEmpty(Id))
|
||||
{
|
||||
navigationManager.NavigateTo("/user/properties");
|
||||
}
|
||||
else
|
||||
{
|
||||
CompanyId = Guid.Parse(Id);
|
||||
}
|
||||
base.OnParametersSet();
|
||||
}
|
||||
|
||||
void Grid_CustomizeElement(GridCustomizeElementEventArgs e)
|
||||
{
|
||||
//TODO mark non active partners
|
||||
|
||||
}
|
||||
|
||||
void Grid_CustomizeEditModel(GridCustomizeEditModelEventArgs e)
|
||||
{
|
||||
if (!e.IsNew)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
var companyEditModel = (Company)e.EditModel; //TODO not valid cast
|
||||
companyEditModel.Id = Guid.NewGuid();
|
||||
companyEditModel.AffiliateId = Guid.NewGuid();
|
||||
companyEditModel.Name = "Company name";
|
||||
companyEditModel.OwnerId = Guid.Empty;
|
||||
companyEditModel.ProfileId = Guid.NewGuid();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
</BodyContentTemplate>
|
||||
<FooterContentTemplate>
|
||||
<DxButton CssClass="popup-button my-1 ms-2" RenderStyle="ButtonRenderStyle.Primary" Text="OK" Click="@(() => _setOwnerPopupVisible = false)" />
|
||||
<DxButton CssClass="popup-button my-1 ms-2" RenderStyle="ButtonRenderStyle.Primary" Text="OK" Click="@SetOwner" />
|
||||
@* <DxButton CssClass="popup-button my-1 ms-2" RenderStyle="ButtonRenderStyle.Secondary" Text="Cancel" Click="@(() => SetOwnerPopupVisible = false)" /> *@
|
||||
</FooterContentTemplate>
|
||||
</DxPopup>
|
||||
|
|
@ -125,7 +125,17 @@
|
|||
<CompaniesNestedUserProductMapping CurrentCompany="(TIAM.Entities.ServiceProviders.Company)context.DataItem" KeyboardNavigationEnabled="true" />
|
||||
</DetailRowTemplate> *@
|
||||
<DetailRowTemplate>
|
||||
<AddressDetailGridComponent ParentData="((Company)context.DataItem).Profile" OnAddressChanged="AddressChanged" KeyboardNavigationEnabled="true" />
|
||||
<DxTabs>
|
||||
<DxTabPage Text="Profile">
|
||||
<ProfileGridComponent ProfileId="((Company)context.DataItem).ProfileId" KeyboardNavigationEnabled="true" />
|
||||
</DxTabPage>
|
||||
<DxTabPage Text="Products">
|
||||
<ProductDetailGridComponent ContextId="((Company)context.DataItem).Id" KeyboardNavigationEnabled="true" />
|
||||
</DxTabPage>
|
||||
<DxTabPage Text="Address">
|
||||
<AddressDetailGridComponent ParentData="((Company)context.DataItem).Profile" KeyboardNavigationEnabled="true" />
|
||||
</DxTabPage>
|
||||
</DxTabs>
|
||||
</DetailRowTemplate>
|
||||
<EditFormTemplate Context="EditFormContext">
|
||||
@{
|
||||
|
|
@ -163,6 +173,8 @@
|
|||
private CompanyGrid _gridCompany;
|
||||
private bool _autoCollapseDetailRow;
|
||||
|
||||
private Company CompanyToSetOwner = null;
|
||||
|
||||
public List<string> IgnoreList =
|
||||
[
|
||||
"ReceiverEmailAddress",
|
||||
|
|
@ -181,14 +193,6 @@
|
|||
DateTime StartDate { get; set; } = DateTime.Today;
|
||||
DxSchedulerDataStorage _dataStorage = new();
|
||||
|
||||
private void AddressChanged(Address address)
|
||||
{
|
||||
_logger.Debug($"DataItemSaving; addressId: {address?.Id}");
|
||||
|
||||
// var company = _gridCompany.DataSource!.FirstOrDefault(x => x.Profile.AddressId == address.Id);
|
||||
// company.Profile.Address = address;
|
||||
}
|
||||
|
||||
void SendMail(Company item)
|
||||
{
|
||||
_logger.Info($"Sending mail to {item.OwnerId}, {item.Id}");
|
||||
|
|
@ -203,26 +207,27 @@
|
|||
void SetOwnerPopup(Company item)
|
||||
{
|
||||
_logger.Info($"Setting owner of {item.OwnerId}, {item.Id}");
|
||||
|
||||
CompanyToSetOwner = item;
|
||||
_setOwnerPopupVisible = true;
|
||||
}
|
||||
|
||||
async Task<Company> SetOwner(Guid CompanyId)
|
||||
async Task<Company> SetOwner()
|
||||
{
|
||||
|
||||
//get user id from DB
|
||||
var userModelDto = await userDataService.GetUserByEmailAsync(Email);
|
||||
|
||||
//overwrite ServiceProvider ownerid
|
||||
var target = await serviceProviderDataService.GetServiceProviderByIdAsync(CompanyId);
|
||||
if (target == null)
|
||||
//var target = await serviceProviderDataService.GetServiceProviderByIdAsync(CompanyToSetOwner.Id);
|
||||
if (CompanyToSetOwner == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
target.OwnerId = userModelDto.Id;
|
||||
var result = await serviceProviderDataService.UpdateServiceProviderAsync(target);
|
||||
|
||||
CompanyToSetOwner.OwnerId = userModelDto.Id;
|
||||
var result = await serviceProviderDataService.UpdateServiceProviderAsync(CompanyToSetOwner);
|
||||
CompanyToSetOwner = null;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -154,31 +154,6 @@
|
|||
<TransferToDriverGridComponent ParentData="(Transfer)context.DataItem" KeyboardNavigationEnabled="true" />
|
||||
</DxTabPage>
|
||||
<DxTabPage Text="Messages">
|
||||
<MessageDetailGrid
|
||||
Logger="_logger"
|
||||
SignalRClient="AdminSignalRClient"
|
||||
ContextId="((Transfer)context.DataItem).Id">
|
||||
|
||||
<Columns>
|
||||
<DxGridDataColumn FieldName="Id" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" DisplayFormat="N" />
|
||||
<DxGridDataColumn FieldName="ContextId" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" DisplayFormat="N" />
|
||||
<DxGridDataColumn FieldName="EmailAddress" />
|
||||
<DxGridDataColumn FieldName="Subject" />
|
||||
<DxGridDataColumn FieldName="Text">
|
||||
<CellDisplayTemplate Context="displayTextContext">
|
||||
<text>@System.Text.RegularExpressions.Regex.Replace((displayTextContext.Value as string)!, "<(.|\n)*?>", string.Empty)</text>
|
||||
|
||||
</CellDisplayTemplate>
|
||||
<CellEditTemplate Context="editTextContext">
|
||||
@{
|
||||
var value = ((EmailMessage)editTextContext.EditModel).Text;
|
||||
<textarea>@value</textarea>
|
||||
}
|
||||
</CellEditTemplate>
|
||||
</DxGridDataColumn>
|
||||
<DxGridDataColumn FieldName="Created" DisplayFormat="g" Width="140" />
|
||||
</Columns>
|
||||
</MessageDetailGrid>
|
||||
<MessageDetailGridComponent ContextId="((Transfer)context.DataItem).Id" KeyboardNavigationEnabled="true" />
|
||||
</DxTabPage>
|
||||
</DxTabs>
|
||||
|
|
|
|||
|
|
@ -29,8 +29,8 @@
|
|||
CloseOnOutsideClick="false"
|
||||
ShowCloseButton="false"
|
||||
HeaderText="MessageBox"
|
||||
Closing="EulaPopupClosing"
|
||||
Closed="EulaPopupClosed">
|
||||
Closing="EmailPopupClosing"
|
||||
Closed="EmailPopupClosed">
|
||||
<BodyContentTemplate>
|
||||
<InputWizard Data=@MessageWizardModel
|
||||
OnSubmit="SubmitForm"
|
||||
|
|
@ -75,7 +75,7 @@
|
|||
KeyFieldName="Id">
|
||||
|
||||
<Columns>
|
||||
<DxGridCommandColumn NewButtonVisible="false" Width="8%" FixedPosition="GridColumnFixedPosition.Left" />
|
||||
<DxGridCommandColumn NewButtonVisible="true" Width="8%" FixedPosition="GridColumnFixedPosition.Left" />
|
||||
<DxGridDataColumn Name="@Localizer.GetString("Id")" FieldName="Id" ShowInColumnChooser="false" SortIndex="0" Visible="false" />
|
||||
<DxGridDataColumn Name="@Localizer.GetString("FullName")" FieldName="ProfileDto.FullName" />
|
||||
<DxGridDataColumn Name="@Localizer.GetString("PhoneNumber")" FieldName="UserDto.PhoneNumber" />
|
||||
|
|
@ -89,18 +89,21 @@
|
|||
var keyItem = (UserModelDtoDetail)context.DataItem;
|
||||
|
||||
var buttonText = "Contact";
|
||||
<DxButton Click="() => SendMail(keyItem)" Text="@buttonText" RenderStyle="ButtonRenderStyle.Primary" />
|
||||
<p>@keyField </p><DxButton Click="() => SendMail(keyItem)" Text="@buttonText" RenderStyle="ButtonRenderStyle.Primary" />
|
||||
}
|
||||
</CellDisplayTemplate>
|
||||
</DxGridDataColumn>
|
||||
</Columns>
|
||||
<DetailRowTemplate>
|
||||
<DxTabs>
|
||||
<DxTabPage Text="Profile">
|
||||
<ProfileGridComponent ProfileId="((UserModelDtoDetail)context.DataItem).ProfileDto.Id" KeyboardNavigationEnabled="true" />
|
||||
</DxTabPage>
|
||||
<DxTabPage Text="Address">
|
||||
<AddressDetailGridComponent ParentData="((UserModelDtoDetail)context.DataItem).ProfileDto" KeyboardNavigationEnabled="true" />
|
||||
</DxTabPage>
|
||||
<DxTabPage Text="Companies owned">
|
||||
<ServiceProviderGridComponent UserModelDtoDetail="(UserModelDtoDetail)context.DataItem" />
|
||||
<ServiceProviderGridComponent ContextId="((UserModelDtoDetail)context.DataItem).Id" />
|
||||
</DxTabPage>
|
||||
<DxTabPage Text="Roles in services">
|
||||
<UserProductMappingGridComponent UserModelDtoDetail="(UserModelDtoDetail)context.DataItem" KeyboardNavigationEnabled="true" />
|
||||
|
|
@ -194,12 +197,12 @@
|
|||
PopupVisible = false;
|
||||
}
|
||||
|
||||
void EulaPopupClosed()
|
||||
void EmailPopupClosed()
|
||||
{
|
||||
//cancel clicked
|
||||
}
|
||||
|
||||
void EulaPopupClosing(PopupClosingEventArgs args)
|
||||
void EmailPopupClosing(PopupClosingEventArgs args)
|
||||
{
|
||||
//myModel = new TransferWizardModel();
|
||||
MessageWizardModel = new MessageWizardModel();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,142 @@
|
|||
@using TIAM.Entities.Products
|
||||
@using TIAM.Entities.ServiceProviders
|
||||
@using TIAM.Entities.Transfers
|
||||
@using TIAM.Entities.Drivers
|
||||
@using TIAM.Entities.Users
|
||||
@using TIAM.Models.Dtos.Users
|
||||
@using TIAM.Resources
|
||||
@using TIAMWebApp.Shared.Application.Interfaces
|
||||
@using TIAMWebApp.Shared.Application.Utility
|
||||
@using AyCode.Services.Loggers
|
||||
@using TIAM.Core.Loggers
|
||||
@using Address = TIAM.Entities.Addresses.Address
|
||||
@using Profile = TIAM.Entities.Profiles.Profile
|
||||
@using TIAMSharedUI.Shared.Components.Grids
|
||||
@using TIAMSharedUI.Pages.Components.EditComponents
|
||||
@using TIAMWebApp.Shared.Application.Services
|
||||
@using AyCode.Interfaces.Addresses
|
||||
@inject IStringLocalizer<TIAMResources> Localizer
|
||||
@inject IServiceProviderDataService serviceProviderDataService
|
||||
@inject IUserDataService userDataService
|
||||
@inject ITransferDataService transferDataService
|
||||
@inject IEnumerable<IAcLogWriterClientBase> LogWriters
|
||||
@inject AdminSignalRClient AdminSignalRClient;
|
||||
|
||||
|
||||
<ProductDetailGrid @ref="_productGrid"
|
||||
ContextId="ContextId"
|
||||
Logger="_logger"
|
||||
SignalRClient="AdminSignalRClient"
|
||||
OnGridEditModelSaving="DataItemSaving"
|
||||
OnGridItemDeleting="DataItemDeleting"
|
||||
OnGridItemChanged="DataItemChanged"
|
||||
PageSize="5"
|
||||
AutoExpandAllGroupRows="true"
|
||||
KeyboardNavigationEnabled="KeyboardNavigationEnabled"
|
||||
KeyFieldName="Id"
|
||||
ValidationEnabled="false"
|
||||
EditMode="GridEditMode.EditForm"
|
||||
ColumnResizeMode="GridColumnResizeMode.NextColumn"
|
||||
ShowFilterRow="true">
|
||||
<Columns>
|
||||
<DxGridCommandColumn NewButtonVisible="true" Width="8%" FixedPosition="GridColumnFixedPosition.Left" />
|
||||
<DxGridDataColumn FieldName="Id" GroupIndex="0" />
|
||||
<DxGridDataColumn Caption=@Localizer.GetString(ResourceKeys.ProductName) FieldName="Name" />
|
||||
<DxGridDataColumn Caption=@Localizer.GetString(ResourceKeys.ProductType) FieldName="ProductType" Width="140" />
|
||||
<DxGridDataColumn Caption=@Localizer.GetString(ResourceKeys.Price) FieldName="Price" Width="40" />
|
||||
<DxGridDataColumn FieldName="ServiceProviderId" Width="40" />
|
||||
<DxGridDataColumn Caption=@Localizer.GetString(ResourceKeys.ProductDescription) FieldName="Description" Width="40" />
|
||||
</Columns>
|
||||
<DetailRowTemplate>
|
||||
<DxTabs>
|
||||
<DxTabPage Text="Profile">
|
||||
<ProfileGridComponent ProfileId="((Product)context.DataItem).ProfileId" KeyboardNavigationEnabled="true" />
|
||||
</DxTabPage>
|
||||
</DxTabs>
|
||||
</DetailRowTemplate>
|
||||
<EditFormTemplate Context="EditFormContext">
|
||||
@{
|
||||
var transfer2 = (Product)EditFormContext.EditModel;
|
||||
}
|
||||
<DxFormLayout CssClass="w-100">
|
||||
<DxFormLayoutItem Caption=@Localizer.GetString(ResourceKeys.ProductName) ColSpanMd="4">
|
||||
@EditFormContext.GetEditor("Name")
|
||||
</DxFormLayoutItem>
|
||||
<DxFormLayoutItem Caption=@Localizer.GetString(ResourceKeys.ProductType) ColSpanMd="4">
|
||||
@EditFormContext.GetEditor("ProductType")
|
||||
</DxFormLayoutItem>
|
||||
<DxFormLayoutItem Caption=@Localizer.GetString(ResourceKeys.Price) ColSpanMd="4">
|
||||
@EditFormContext.GetEditor("Price")
|
||||
</DxFormLayoutItem>
|
||||
<DxFormLayoutItem Caption=@Localizer.GetString(ResourceKeys.ProductDescription) ColSpanMd="4">
|
||||
@EditFormContext.GetEditor("Description")
|
||||
</DxFormLayoutItem>
|
||||
|
||||
|
||||
</DxFormLayout>
|
||||
</EditFormTemplate>
|
||||
|
||||
</ProductDetailGrid>
|
||||
|
||||
@code {
|
||||
[Parameter] public bool KeyboardNavigationEnabled { get; set; }
|
||||
[Parameter] public Guid? ContextId { get; set; }
|
||||
|
||||
private ProductDetailGrid _productGrid = null!;
|
||||
private LoggerClient<ProductDetailGridComponent> _logger = null!;
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
_logger = new LoggerClient<ProductDetailGridComponent>(LogWriters.ToArray());
|
||||
|
||||
//DataSource = new List<Address>();
|
||||
|
||||
}
|
||||
|
||||
private void DataItemChanged(GridDataItemChangedEventArgs<Product> args)
|
||||
{
|
||||
_logger.Debug($"Saving: {args.DataItem.Name}, {args.DataItem.ServiceProviderId}");
|
||||
|
||||
_productGrid.SaveChangesAsync();
|
||||
}
|
||||
|
||||
private void DataItemSaving(GridEditModelSavingEventArgs e)
|
||||
{
|
||||
_logger.Debug($"DataItemSaving");
|
||||
((Product)e.EditModel).ServiceProviderId = (Guid)ContextId!;
|
||||
Guid _profileId = Guid.NewGuid();
|
||||
((Product)e.EditModel).Profile = new Profile();
|
||||
((Product)e.EditModel).Profile.Id = _profileId;
|
||||
((Product)e.EditModel).ProfileId = _profileId;
|
||||
((Product)e.EditModel).Profile.Name = ((Product)e.EditModel).Name;
|
||||
Guid _addressId = Guid.NewGuid();
|
||||
((Product)e.EditModel).Profile.Address = new Address();
|
||||
((Product)e.EditModel).Profile.AddressId = _addressId;
|
||||
((Product)e.EditModel).Profile.Address.Id = _addressId;
|
||||
|
||||
|
||||
|
||||
_logger.Debug($"Saving: {((Product)e.EditModel).Name}, {((Product)e.EditModel).ServiceProviderId}");
|
||||
|
||||
//var result = serviceProviderDataService.CreateProductAsync((Product)e.EditModel);
|
||||
_logger.Debug($"saved product: {((Product)e.EditModel).ServiceProviderId}");
|
||||
}
|
||||
|
||||
private void DataItemDeleting(GridDataItemDeletingEventArgs obj)
|
||||
{
|
||||
_logger.Debug($"DataItemDeleting");
|
||||
}
|
||||
|
||||
void CustomizeEditModel(GridCustomizeEditModelEventArgs e)
|
||||
{
|
||||
if (!e.IsNew) return;
|
||||
|
||||
var newProduct = (Product)e.EditModel;
|
||||
newProduct.Id = Guid.NewGuid();
|
||||
newProduct.Name = "Type a name";
|
||||
newProduct.ServiceProviderId = (Guid)ContextId!;
|
||||
newProduct.Price = 0;
|
||||
newProduct.ProductType = TIAM.Core.Enums.ProductType.Hotel;
|
||||
newProduct.Description = "Type a description";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,86 +1,73 @@
|
|||
@using TIAM.Entities.Products
|
||||
@using TIAM.Entities.ServiceProviders
|
||||
@using TIAM.Models.Dtos.Users
|
||||
@using TIAMSharedUI.Shared.Components.Grids
|
||||
@using TIAMWebApp.Shared.Application.Interfaces
|
||||
@using TIAMWebApp.Shared.Application.Services
|
||||
@using TIAMWebApp.Shared.Application.Utility
|
||||
@using AyCode.Services.Loggers
|
||||
@using TIAM.Core.Loggers
|
||||
@using AyCode.Core
|
||||
@using Profile = TIAM.Entities.Profiles.Profile
|
||||
@inject IServiceProviderDataService serviceProviderDataService
|
||||
@inject IUserDataService userDataService
|
||||
@inject IEnumerable<IAcLogWriterClientBase> LogWriters
|
||||
|
||||
<div class="mb-2">
|
||||
<h3>Profile</h3>
|
||||
</div>
|
||||
<DxGrid Data="_detailGridData"
|
||||
@inject AdminSignalRClient AdminSignalRClient
|
||||
<ProfileDetailGrid @ref="_profileGrid"
|
||||
ContextId="ProfileId"
|
||||
Logger="_logger"
|
||||
SignalRClient="AdminSignalRClient"
|
||||
PageSize="5"
|
||||
AutoExpandAllGroupRows="true"
|
||||
KeyboardNavigationEnabled="KeyboardNavigationEnabled"
|
||||
KeyFieldName="Id"
|
||||
ValidationEnabled="false"
|
||||
CustomizeEditModel="CustomizeEditModel"
|
||||
EditModelSaving="EditModelSaving"
|
||||
DataItemDeleting="DataItemDeleting"
|
||||
EditMode="GridEditMode.EditForm"
|
||||
ColumnResizeMode="GridColumnResizeMode.NextColumn"
|
||||
ShowFilterRow="true">
|
||||
ShowFilterRow="false">
|
||||
<Columns>
|
||||
<DxGridCommandColumn NewButtonVisible="true" Width="8%" FixedPosition="GridColumnFixedPosition.Left" />
|
||||
<DxGridCommandColumn NewButtonVisible="false" Width="8%" FixedPosition="GridColumnFixedPosition.Left" />
|
||||
<DxGridDataColumn FieldName="Id" GroupIndex="0" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" />
|
||||
<DxGridDataColumn FieldName="UserId" />
|
||||
<DxGridDataColumn FieldName="ProductId" Width="40%" />
|
||||
<DxGridDataColumn FieldName="Permissions" />
|
||||
<DxGridDataColumn FieldName="Name" />
|
||||
<DxGridDataColumn FieldName="FullName" />
|
||||
<DxGridDataColumn FieldName="Created" Width="40%" />
|
||||
<DxGridDataColumn FieldName="Modified" />
|
||||
</Columns>
|
||||
<DetailRowTemplate>
|
||||
<DxTabs>
|
||||
|
||||
<DxTabPage Text="Address">
|
||||
<AddressDetailGridComponent ParentData="((Profile)context.DataItem)" KeyboardNavigationEnabled="true" />
|
||||
</DxTabPage>
|
||||
|
||||
</DxTabs>
|
||||
|
||||
|
||||
</DxGrid>
|
||||
</DetailRowTemplate>
|
||||
|
||||
</ProfileDetailGrid>
|
||||
|
||||
@code {
|
||||
[Parameter]
|
||||
public bool KeyboardNavigationEnabled { get; set; }
|
||||
[Parameter]
|
||||
public object ProfileContext { get; set; }
|
||||
[Parameter]
|
||||
public string ContextIdType { get; set; }
|
||||
public Guid ProfileId { get; set; } = Guid.Empty;
|
||||
|
||||
List<TIAM.Entities.Profiles.Profile> _detailGridData;
|
||||
|
||||
List<TIAM.Entities.Profiles.Profile> _availableProfiles;
|
||||
|
||||
ILogger _logger;
|
||||
private ProfileDetailGrid _profileGrid = null!;
|
||||
private LoggerClient<ProfileGridComponent> _logger = null!;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
|
||||
_logger = new LoggerClient<ProfileGridComponent>(LogWriters.ToArray());
|
||||
if(ContextIdType == null)
|
||||
{
|
||||
//get all profiles from DB
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (ContextIdType)
|
||||
{
|
||||
case ("user"):
|
||||
//get profile for user
|
||||
UserModelDto resultData = (UserModelDto)ProfileContext;
|
||||
_detailGridData.Add(resultData.UserDto.Profile);
|
||||
break;
|
||||
case ("product"):
|
||||
//get profile for product
|
||||
//var resultData2 = await serviceProviderDataService.GetProductById(ContextId); //todo
|
||||
Product resultData2 = (Product)ProfileContext;
|
||||
_detailGridData.Add(resultData2.Profile);
|
||||
break;
|
||||
case ("company"):
|
||||
//get profile for company
|
||||
Company resultData3 = (Company)ProfileContext;
|
||||
_detailGridData.Add(resultData3.Profile);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
_logger.Info($"DetailGridData: {_detailGridData.Count}");
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
|
||||
_logger.DebugConditional(ProfileId.ToString());
|
||||
base.OnParametersSet();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -99,6 +86,7 @@
|
|||
if (e.IsNew)
|
||||
//add new orderData to orderData array
|
||||
_logger.Info("Data added");
|
||||
|
||||
else
|
||||
_logger.Info("Data updated");
|
||||
|
||||
|
|
|
|||
|
|
@ -5,48 +5,58 @@
|
|||
@using TIAM.Entities.Users
|
||||
@using TIAM.Models.Dtos.Users
|
||||
@using TIAMWebApp.Shared.Application.Interfaces
|
||||
@using TIAMWebApp.Shared.Application.Services
|
||||
@using TIAMWebApp.Shared.Application.Utility
|
||||
@using AyCode.Services.Loggers
|
||||
@using TIAM.Core.Loggers
|
||||
@using AyCode.Core
|
||||
@using TIAMSharedUI.Shared.Components.Grids
|
||||
@inject IServiceProviderDataService ServiceProviderDataService
|
||||
@inject IEnumerable<IAcLogWriterClientBase> LogWriters
|
||||
@inject AdminSignalRClient AdminSignalRClient;
|
||||
|
||||
<div class="mb-2">
|
||||
<h3>Companies owned</h3>
|
||||
</div>
|
||||
<DxGrid Data="_detailGridData"
|
||||
<CompanyDetailGrid Data="_detailGridData"
|
||||
Logger="_logger"
|
||||
SignalRClient="AdminSignalRClient"
|
||||
ContextId="ContextId"
|
||||
PageSize="5"
|
||||
AutoExpandAllGroupRows="true"
|
||||
KeyboardNavigationEnabled="KeyboardNavigationEnabled"
|
||||
KeyFieldName="Id"
|
||||
ValidationEnabled="false"
|
||||
CustomizeEditModel="CustomizeEditModel"
|
||||
EditModelSaving="EditModelSaving"
|
||||
DataItemDeleting="DataItemDeleting"
|
||||
EditMode="GridEditMode.EditForm"
|
||||
ColumnResizeMode="GridColumnResizeMode.NextColumn"
|
||||
ShowFilterRow="true">
|
||||
<Columns>
|
||||
<DxGridCommandColumn Width="135" MinWidth="135" FixedPosition="GridColumnFixedPosition.Left" />
|
||||
<DxGridDataColumn FieldName="Id" GroupIndex="0" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" />
|
||||
<DxGridDataColumn FieldName="UserId" />
|
||||
<DxGridDataColumn FieldName="ProductId" Width="40%" />
|
||||
<DxGridDataColumn FieldName="Permissions" />
|
||||
<DxGridDataColumn FieldName="OwnerId" />
|
||||
<DxGridDataColumn FieldName="Name" Width="40%" />
|
||||
<DxGridDataColumn FieldName="AffiliateId" />
|
||||
<DxGridDataColumn FieldName="CommissionPercent" />
|
||||
</Columns>
|
||||
<DetailRowTemplate>
|
||||
|
||||
<DxTabs>
|
||||
<DxTabPage Text="Products">
|
||||
<ProductDetailGridComponent ContextId="((Company)context.DataItem).Id" KeyboardNavigationEnabled="true" />
|
||||
</DxTabPage>
|
||||
|
||||
</DxTabs>
|
||||
|
||||
|
||||
</DetailRowTemplate>
|
||||
<EditFormTemplate Context="EditFormContext">
|
||||
@{
|
||||
var transfer2 = (UserProductMapping)EditFormContext.EditModel;
|
||||
var serviceProvider = (Company)EditFormContext.EditModel;
|
||||
}
|
||||
<DxFormLayout CssClass="w-100">
|
||||
<DxFormLayoutItem Caption="UserId" ColSpanMd="4">
|
||||
@EditFormContext.GetEditor("UserId")
|
||||
<DxFormLayoutItem Caption="Name" ColSpanMd="4">
|
||||
@EditFormContext.GetEditor("Name")
|
||||
</DxFormLayoutItem>
|
||||
<DxFormLayoutItem Caption="Product:" ColSpanMd="4">
|
||||
<DxComboBox Data="@_availableServices" TextFieldName="Name" @bind-Value="((UserProductMapping)EditFormContext.EditModel).ProductId" />
|
||||
</DxFormLayoutItem>
|
||||
<DxFormLayoutItem Caption="Permissions" ColSpanMd="4">
|
||||
@EditFormContext.GetEditor("Permissions")
|
||||
|
||||
<DxFormLayoutItem Caption="Commission rate" ColSpanMd="4">
|
||||
@EditFormContext.GetEditor("CommissionPercent")
|
||||
</DxFormLayoutItem>
|
||||
|
||||
|
||||
|
|
@ -54,13 +64,12 @@
|
|||
</DxFormLayout>
|
||||
</EditFormTemplate>
|
||||
|
||||
</DxGrid>
|
||||
</CompanyDetailGrid>
|
||||
|
||||
@code {
|
||||
[Parameter]
|
||||
public bool KeyboardNavigationEnabled { get; set; }
|
||||
[Parameter]
|
||||
public UserModelDtoDetail UserModelDtoDetail { get; set; }
|
||||
[Parameter] public bool KeyboardNavigationEnabled { get; set; }
|
||||
[Parameter] public UserModelDtoDetail UserModelDtoDetail { get; set; }
|
||||
[Parameter] public Guid? ContextId { get; set; }
|
||||
|
||||
List<Company> _detailGridData;
|
||||
|
||||
|
|
@ -68,54 +77,54 @@
|
|||
|
||||
public UserModelDtoDetail UserInfo;
|
||||
|
||||
ILogger _logger;
|
||||
private LoggerClient<ServiceProviderGridComponent> _logger = null!;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
_logger = new LoggerClient<ServiceProviderGridComponent>(LogWriters.ToArray());
|
||||
|
||||
_detailGridData = UserModelDtoDetail.ServiceProviders ?? new List<Company>();
|
||||
_availableServices = await ServiceProviderDataService.GetServiceProvidersAsync();
|
||||
//_detailGridData = UserModelDtoDetail.ServiceProviders ?? new List<Company>();
|
||||
//_availableServices = await ServiceProviderDataService.GetServiceProvidersAsync();
|
||||
|
||||
_logger.Info($"DetailGridData: {_detailGridData.Count}");
|
||||
//_logger.Info($"DetailGridData: {_detailGridData.Count}");
|
||||
}
|
||||
|
||||
void CustomizeEditModel(GridCustomizeEditModelEventArgs e)
|
||||
{
|
||||
if (!e.IsNew) return;
|
||||
// void CustomizeEditModel(GridCustomizeEditModelEventArgs e)
|
||||
// {
|
||||
// if (!e.IsNew) return;
|
||||
|
||||
var newProductMapping = new UserProductMapping
|
||||
{
|
||||
ProductId = Guid.NewGuid(),
|
||||
UserId = UserModelDtoDetail.Id,
|
||||
Permissions = 1
|
||||
};
|
||||
// var newProductMapping = new UserProductMapping
|
||||
// {
|
||||
// ProductId = Guid.NewGuid(),
|
||||
// UserId = UserModelDtoDetail.Id,
|
||||
// Permissions = 1
|
||||
// };
|
||||
|
||||
e.EditModel = newProductMapping;
|
||||
}
|
||||
// e.EditModel = newProductMapping;
|
||||
// }
|
||||
|
||||
async Task EditModelSaving(GridEditModelSavingEventArgs e)
|
||||
{
|
||||
if (e.IsNew)
|
||||
//add new orderData to orderData array
|
||||
_logger.Info("New orderData added");
|
||||
else
|
||||
_logger.Info("orderData updated");
|
||||
// async Task EditModelSaving(GridEditModelSavingEventArgs e)
|
||||
// {
|
||||
// if (e.IsNew)
|
||||
// //add new orderData to orderData array
|
||||
// _logger.Info("New orderData added");
|
||||
// else
|
||||
// _logger.Info("orderData updated");
|
||||
|
||||
await UpdateDataAsync();
|
||||
}
|
||||
|
||||
async Task DataItemDeleting(GridDataItemDeletingEventArgs e)
|
||||
{
|
||||
//remove orderData from orderData array
|
||||
_logger.Info("orderData deleted");
|
||||
// await UpdateDataAsync();
|
||||
}
|
||||
// }
|
||||
|
||||
async Task UpdateDataAsync()
|
||||
{
|
||||
//refresh grid
|
||||
_logger.Info("orderData grid refreshed");
|
||||
}
|
||||
// async Task DataItemDeleting(GridDataItemDeletingEventArgs e)
|
||||
// {
|
||||
// //remove orderData from orderData array
|
||||
// _logger.Info("orderData deleted");
|
||||
// //await UpdateDataAsync();
|
||||
// }
|
||||
|
||||
// async Task UpdateDataAsync()
|
||||
// {
|
||||
// //refresh grid
|
||||
// _logger.Info("orderData grid refreshed");
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
@ -1,9 +1,18 @@
|
|||
using Microsoft.AspNetCore.Components;
|
||||
using TIAM.Services;
|
||||
|
||||
namespace TIAMSharedUI.Shared.Components.Grids;
|
||||
|
||||
public class CompanyDetailGrid : CompanyGrid
|
||||
{
|
||||
public CompanyDetailGrid() : base()
|
||||
{
|
||||
GetAllMessageTag = SignalRTags.GetCompaniesByContextId;
|
||||
AddMessageTag = SignalRTags.AddCompany;
|
||||
UpdateMessageTag = SignalRTags.UpdateCompany;
|
||||
RemoveMessageTag = SignalRTags.RemoveCompany;
|
||||
}
|
||||
|
||||
protected override Task SetParametersAsyncCore(ParameterView parameters)
|
||||
{
|
||||
var isFirst = IsFirstInitializeParameters;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,30 @@
|
|||
using Microsoft.AspNetCore.Components;
|
||||
using TIAM.Entities.Products;
|
||||
using TIAM.Services;
|
||||
|
||||
namespace TIAMSharedUI.Shared.Components.Grids;
|
||||
|
||||
public class ProductDetailGrid : ProductGrid
|
||||
{
|
||||
public ProductDetailGrid() : base()
|
||||
{
|
||||
GetAllMessageTag = SignalRTags.GetProductsByOwnerId;
|
||||
AddMessageTag = SignalRTags.AddProduct;
|
||||
UpdateMessageTag = SignalRTags.UpdateProduct;
|
||||
RemoveMessageTag = SignalRTags.RemoveProduct;
|
||||
}
|
||||
|
||||
protected override Task SetParametersAsyncCore(ParameterView parameters)
|
||||
{
|
||||
if (!IsFirstInitializeParameters)
|
||||
{
|
||||
//ShowFilterRow = true;
|
||||
//ShowGroupPanel = true;
|
||||
//AllowSort = false;
|
||||
|
||||
//etc...
|
||||
}
|
||||
|
||||
return base.SetParametersAsyncCore(parameters);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
using Microsoft.AspNetCore.Components;
|
||||
using TIAM.Entities.Products;
|
||||
using TIAM.Services;
|
||||
|
||||
namespace TIAMSharedUI.Shared.Components.Grids;
|
||||
|
||||
public class ProductGrid : TiamGrid<Product>
|
||||
{
|
||||
public ProductGrid() : base()
|
||||
{
|
||||
GetAllMessageTag = SignalRTags.GetProductsByContextId;
|
||||
AddMessageTag = SignalRTags.AddProduct;
|
||||
UpdateMessageTag = SignalRTags.UpdateProduct;
|
||||
RemoveMessageTag = SignalRTags.RemoveProduct;
|
||||
}
|
||||
|
||||
protected override Task SetParametersAsyncCore(ParameterView parameters)
|
||||
{
|
||||
if (!IsFirstInitializeParameters)
|
||||
{
|
||||
//ShowFilterRow = true;
|
||||
//ShowGroupPanel = true;
|
||||
//AllowSort = false;
|
||||
|
||||
//etc...
|
||||
}
|
||||
|
||||
return base.SetParametersAsyncCore(parameters);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
using Microsoft.AspNetCore.Components;
|
||||
using TIAM.Entities.Profiles;
|
||||
using TIAM.Services;
|
||||
|
||||
namespace TIAMSharedUI.Shared.Components.Grids;
|
||||
|
||||
public class ProfileDetailGrid : ProfileGrid
|
||||
{
|
||||
|
||||
|
||||
protected override Task SetParametersAsyncCore(ParameterView parameters)
|
||||
{
|
||||
if (!IsFirstInitializeParameters)
|
||||
{
|
||||
//ShowFilterRow = true;
|
||||
//ShowGroupPanel = true;
|
||||
//AllowSort = false;
|
||||
|
||||
//etc...
|
||||
}
|
||||
|
||||
return base.SetParametersAsyncCore(parameters);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
using Microsoft.AspNetCore.Components;
|
||||
using TIAM.Entities.Profiles;
|
||||
using TIAM.Services;
|
||||
|
||||
namespace TIAMSharedUI.Shared.Components.Grids;
|
||||
|
||||
public class ProfileGrid : TiamGrid<Profile>
|
||||
{
|
||||
public ProfileGrid() : base()
|
||||
{
|
||||
GetAllMessageTag = SignalRTags.GetProfileById;
|
||||
//AddMessageTag = SignalRTags.AddProfile;
|
||||
UpdateMessageTag = SignalRTags.UpdateProfile;
|
||||
//RemoveMessageTag = SignalRTags.RemoveProfile;
|
||||
}
|
||||
|
||||
protected override Task SetParametersAsyncCore(ParameterView parameters)
|
||||
{
|
||||
if (!IsFirstInitializeParameters)
|
||||
{
|
||||
//ShowFilterRow = true;
|
||||
//ShowGroupPanel = true;
|
||||
//AllowSort = false;
|
||||
|
||||
//etc...
|
||||
}
|
||||
|
||||
return base.SetParametersAsyncCore(parameters);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using QRCoder;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using AyCode.Core.Enums;
|
||||
using AyCode.Core.Extensions;
|
||||
using TIAM.Database.DataLayers.Admins;
|
||||
using TIAM.Entities.ServiceProviders;
|
||||
using TIAM.Entities.Users;
|
||||
using TIAMWebApp.Shared.Application.Models;
|
||||
using Product = TIAM.Entities.Products.Product;
|
||||
using TIAM.Entities.Addresses;
|
||||
using TIAM.Entities.Profiles;
|
||||
using AyCode.Core.Loggers;
|
||||
using AyCode.Entities;
|
||||
using AyCode.Services.SignalRs;
|
||||
using AyCode.Utils.Extensions;
|
||||
using TIAM.Entities.Drivers;
|
||||
using TIAM.Services;
|
||||
|
||||
namespace TIAMWebApp.Server.Controllers
|
||||
{
|
||||
[Authorize]
|
||||
[ApiController]
|
||||
[Route("api/v1/[controller]")]
|
||||
public class ProfileAPIController(AdminDal adminDal, IEnumerable<IAcLogWriterBase> logWriters) : ControllerBase
|
||||
{
|
||||
private readonly TIAM.Core.Loggers.Logger<ServiceProviderAPIController> _logger = new(logWriters.ToArray());
|
||||
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpGet]
|
||||
[Route(APIUrls.GetProfileByIdRouteName)]
|
||||
[SignalR(SignalRTags.GetProfileById)]
|
||||
public async Task<string> GetProfileById([FromBody] Guid id)
|
||||
{
|
||||
if (id != Guid.Empty)
|
||||
{
|
||||
_logger.Info($@"GetServiceProviderById called with id: {id}");
|
||||
var result = await adminDal.GetProfileByIdAsync(id);
|
||||
List<Profile> profiles = new List<Profile>();
|
||||
if (result != null)
|
||||
profiles.Add(result);
|
||||
var jsonResult = profiles.ToJson();
|
||||
return jsonResult;
|
||||
}
|
||||
else {
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpPost]
|
||||
[Route(APIUrls.UpdateProfileRouteName)]
|
||||
[SignalR(SignalRTags.UpdateProfile)]
|
||||
public async Task<string> UpdateProfile(Profile profile)
|
||||
{
|
||||
_logger.Info($"UpdateUserProductMapping called! + {profile.Id}");
|
||||
|
||||
var result = await adminDal.UpdateProfileAsync(profile);
|
||||
|
||||
return result ? profile.ToJson() : string.Empty;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -138,6 +138,24 @@ namespace TIAMWebApp.Server.Controllers
|
|||
return myServiceproviders;
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost]
|
||||
[Route(APIUrls.GetCompaniesByContextIdRouteName)]
|
||||
[Tags("Finished", "ServiceProvider")]
|
||||
[SignalR(SignalRTags.GetCompaniesByContextId)]
|
||||
public async Task<string> GetCompaniesByContextId([FromBody] Guid ownerId)
|
||||
{
|
||||
_logger.Info($@"GetServiceProvidersByOwnerId called with ownerId: {ownerId}");
|
||||
|
||||
var serviceProviders = await adminDal.GetServiceProvidersByOwnerIdAsync(ownerId);
|
||||
|
||||
//return serviceProviders.Where(x => x.OwnerId == ownerId).ToList();
|
||||
//var myServiceproviders = serviceProviders.Where(x => x.OwnerId == ownerId).ToDictionary(x => x.Id, x => x.Name);
|
||||
//put Company id and name into a dictionary
|
||||
|
||||
return serviceProviders.ToJson();
|
||||
}
|
||||
|
||||
//22.
|
||||
[AllowAnonymous]
|
||||
[HttpPost]
|
||||
|
|
@ -278,8 +296,10 @@ namespace TIAMWebApp.Server.Controllers
|
|||
[HttpPost]
|
||||
[Route(APIUrls.AddProductRouteName)]
|
||||
[Tags("In-Progress", "Product")]
|
||||
[SignalR(SignalRTags.AddProduct)]
|
||||
public async Task<IActionResult> AddProduct([FromBody] Product product)
|
||||
{
|
||||
|
||||
_logger.Info(@"AddProduct called");
|
||||
|
||||
if (product == null)
|
||||
|
|
@ -289,7 +309,7 @@ namespace TIAMWebApp.Server.Controllers
|
|||
else
|
||||
{
|
||||
var result = adminDal.AddProductAsync(product);
|
||||
return Ok(result);
|
||||
return Ok(product);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -326,31 +346,50 @@ namespace TIAMWebApp.Server.Controllers
|
|||
}
|
||||
}
|
||||
|
||||
[NonAction]
|
||||
[ApiExplorerSettings(IgnoreApi = true)]
|
||||
public async Task<string> GetProductsByOwnerId(Guid serviceProviderId)
|
||||
{
|
||||
_logger.Info($@"GetProductsByServiceProviderId called with serviceProviderId: {serviceProviderId}");
|
||||
|
||||
if (serviceProviderId != Guid.Empty)
|
||||
{
|
||||
var products = adminDal.GetProductsJsonByServiceProviderId(serviceProviderId);
|
||||
if (products != null)
|
||||
{
|
||||
return await Task.FromResult(products);
|
||||
}
|
||||
else
|
||||
{
|
||||
//some Iactionresult that explains that there were errors
|
||||
return await Task.FromResult(string.Empty);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//some Iactionresult that explains that there were errors
|
||||
return await Task.FromResult(string.Empty);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
[AllowAnonymous]
|
||||
[HttpPost]
|
||||
[Route(APIUrls.GetProductsByServiceProviderIdRouteName)]
|
||||
[Tags("In-Progress", "Product")]
|
||||
public IActionResult GetProductsByServiceProviderId([FromBody] Guid serviceProviderId)
|
||||
[SignalR(SignalRTags.GetProductsByOwnerId)]
|
||||
public async Task<string> GetProductsByServiceProviderId([FromBody] Guid serviceProviderId)
|
||||
{
|
||||
_logger.Info($@"GetProductsByServiceProviderId called with serviceProviderId: {serviceProviderId}");
|
||||
|
||||
if (serviceProviderId == Guid.Empty)
|
||||
{
|
||||
return BadRequest("Invalid request");
|
||||
return await Task.FromResult("Invalid request");
|
||||
}
|
||||
else
|
||||
{
|
||||
var products = adminDal.GetProductsJsonByServiceProviderId(serviceProviderId);
|
||||
if (products != null)
|
||||
{
|
||||
return Ok(products);
|
||||
}
|
||||
else
|
||||
{
|
||||
//some Iactionresult that explains that there were errors
|
||||
return StatusCode(500);
|
||||
|
||||
}
|
||||
var result = await GetProductsByOwnerId(serviceProviderId);
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ builder.Services.AddSingleton<AuthService>();
|
|||
builder.Services.AddScoped<ServiceProviderAPIController>();
|
||||
builder.Services.AddScoped<TransferDataAPIController>();
|
||||
builder.Services.AddScoped<MessageAPIController>();
|
||||
builder.Services.AddScoped<ProfileAPIController>();
|
||||
|
||||
|
||||
builder.Services.AddSignalR(options => options.MaximumReceiveMessageSize = 128 * 1024);//.AddMessagePackProtocol(options => options.SerializerOptions = MessagePackSerializerOptions.Standard.WithSecurity(MessagePackSecurity.UntrustedData));
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ public class DevAdminSignalRHub : Hub<ISignalRHubItemServer>, IAcSignalRHubServe
|
|||
//private readonly ServiceProviderAPIController _serviceProviderApiController;
|
||||
//private readonly TransferDataAPIController _transferDataApiController;
|
||||
|
||||
public DevAdminSignalRHub(AdminDal adminDal, ServiceProviderAPIController serviceProviderApiController, TransferDataAPIController transferDataApiController, MessageAPIController messageApiController, IEnumerable<IAcLogWriterBase> logWriters)
|
||||
public DevAdminSignalRHub(AdminDal adminDal, ServiceProviderAPIController serviceProviderApiController, TransferDataAPIController transferDataApiController, MessageAPIController messageApiController, ProfileAPIController profileApiController, IEnumerable<IAcLogWriterBase> logWriters)
|
||||
{
|
||||
_adminDal = adminDal;
|
||||
//_serviceProviderApiController = serviceProviderApiController;
|
||||
|
|
@ -101,6 +101,7 @@ public class DevAdminSignalRHub : Hub<ISignalRHubItemServer>, IAcSignalRHubServe
|
|||
_dynamicMethodCallModels.Add(new DynamicMethodCallModel<SignalRAttribute>(serviceProviderApiController));
|
||||
_dynamicMethodCallModels.Add(new DynamicMethodCallModel<SignalRAttribute>(transferDataApiController));
|
||||
_dynamicMethodCallModels.Add(new DynamicMethodCallModel<SignalRAttribute>(messageApiController));
|
||||
_dynamicMethodCallModels.Add(new DynamicMethodCallModel<SignalRAttribute>(profileApiController));
|
||||
//_dynamicMethodCallModels.Add(new DynamicMethodCallModel<SignalRAttribute>(typeof(AdminDal)));
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ namespace TIAMWebApp.Shared.Application.Interfaces
|
|||
public Task<Company?> GetServiceProviderByIdAsync(Guid id);
|
||||
|
||||
//19. (IServiceProviderDataService) Create product
|
||||
public Task<bool> CreateProductAsync(Product product);
|
||||
public Task<Product> CreateProductAsync(Product product);
|
||||
|
||||
//20. (IServiceProviderDataService) Update product
|
||||
public Task<bool> UpdateProductAsync(Product product);
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ namespace TIAMWebApp.Shared.Application.Models
|
|||
public const string LoggerApi = BaseUrlWithSlashAndVersion + "LoggerApi/";
|
||||
|
||||
public const string UserAPI = BaseUrlWithSlashAndVersion + "UserAPI/";
|
||||
public const string ProfileAPI = BaseUrlWithSlashAndVersion + "ProfileAPI/";
|
||||
public const string WeatherForecastAPI = BaseUrlWithSlashAndVersion + "WeatherForecastAPI/";
|
||||
public const string PopulationStructureAPI = BaseUrlWithSlashAndVersion + "PopulationStructureAPI/";
|
||||
public const string TransferDataAPI = BaseUrlWithSlashAndVersion + "TransferDataAPI/";
|
||||
|
|
@ -111,6 +112,9 @@ namespace TIAMWebApp.Shared.Application.Models
|
|||
public const string GetServiceProvidersByOwnerIdRouteName = "GetServiceProvidersByOwnerId";
|
||||
public const string GetServiceProvidersByOwnerId = ServiceProviderAPI+GetServiceProvidersByOwnerIdRouteName;
|
||||
|
||||
public const string GetCompaniesByContextIdRouteName = "GetCompaniesByContextId";
|
||||
public const string GetCompaniesByContextId = ServiceProviderAPI + GetCompaniesByContextIdRouteName;
|
||||
|
||||
public const string UpdateServiceProviderRouteName = "UpdateServiceProvider";
|
||||
public const string UpdateServiceProviderUrl = ServiceProviderAPI + UpdateServiceProviderRouteName;
|
||||
|
||||
|
|
@ -123,7 +127,7 @@ namespace TIAMWebApp.Shared.Application.Models
|
|||
public const string GetQrCodeByProductId = ServiceProviderAPI+GetQrCodeByProductIdRouteName;
|
||||
|
||||
public const string AddProductRouteName = "AddProduct";
|
||||
public const string AddProductRouteUrl = ServiceProviderAPI + AddProductRouteName;
|
||||
public const string AddProduct = ServiceProviderAPI + AddProductRouteName;
|
||||
|
||||
public const string GetAllProductsRouteName = "GetAllProducts/";
|
||||
public const string GetAllProducts = ServiceProviderAPI + GetAllProductsRouteName;
|
||||
|
|
@ -158,6 +162,12 @@ namespace TIAMWebApp.Shared.Application.Models
|
|||
public const string DeleteCarRouteName = "DeleteCar";
|
||||
public const string DeleteCar = ServiceProviderAPI + DeleteCarRouteName;
|
||||
|
||||
public const string GetProfileByIdRouteName = "GetProfileById";
|
||||
public const string GetProfileById = ProfileAPI + GetProfileByIdRouteName;
|
||||
|
||||
public const string UpdateProfileRouteName = "UpdateProfile";
|
||||
public const string UpdateProfile = ProfileAPI + UpdateProfileRouteName;
|
||||
|
||||
//AssingedUsers
|
||||
//public const string CreateAssignedUserRouteName = "CreateAssignedUser";
|
||||
//public const string CreateAssignedUser = ServiceProviderAPI + CreateAssignedUserRouteName;
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ using TIAMWebApp.Shared.Application.Models;
|
|||
using TIAMWebApp.Shared.Application.Models.ClientSide;
|
||||
using TIAMWebApp.Shared.Application.Utility;
|
||||
using TIAM.Services;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace TIAMWebApp.Shared.Application.Services
|
||||
{
|
||||
|
|
@ -38,9 +39,32 @@ namespace TIAMWebApp.Shared.Application.Services
|
|||
}
|
||||
|
||||
//19.
|
||||
public Task<bool> CreateProductAsync(Product product)
|
||||
public async Task<Product> CreateProductAsync(Product product)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
var result = await _adminSignalRClient.PostDataAsync(SignalRTags.AddProduct, product);
|
||||
|
||||
return result;
|
||||
|
||||
//var url = $"{Setting.ApiBaseUrl}/{APIUrls.AddProduct}";
|
||||
//var response = await http.PostAsJsonAsync(url, product);
|
||||
//if (response != null)
|
||||
//{
|
||||
// var resultCompany = await response.Content.ReadFromJsonAsync(typeof(Product));
|
||||
// if (resultCompany != null)
|
||||
// {
|
||||
|
||||
// return (resultCompany as Product)!;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return null;
|
||||
// }
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// return null;
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
//15.
|
||||
|
|
@ -129,9 +153,12 @@ namespace TIAMWebApp.Shared.Application.Services
|
|||
}
|
||||
|
||||
//18.
|
||||
public Task<Company?> GetServiceProviderByIdAsync(Guid id)
|
||||
public async Task<Company?> GetServiceProviderByIdAsync(Guid id)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
var company = await _adminSignalRClient.GetByIdAsync<Company>(SignalRTags.GetCompany, id);
|
||||
if (company != null) _logger.DetailConditional($"company: {company.Name}");
|
||||
|
||||
return company;
|
||||
}
|
||||
|
||||
//16.
|
||||
|
|
|
|||
Loading…
Reference in New Issue