From b2711064b4237ee0eac3e3951d82b55430de26aa Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 17 Jun 2024 11:04:11 +0200 Subject: [PATCH 1/2] razor pages --- TIAMSharedUI/Pages/EditTransfers.razor | 116 +++++++++++++++++- .../User/SysAdmins/ManageTransfers.razor | 20 +-- .../MessageDetailGridComponent.razor | 67 ++++++++++ .../User/SysAdmins/MessageGridComponent.razor | 65 ++++++++++ .../Controllers/TransferDataAPIController.cs | 4 +- 5 files changed, 252 insertions(+), 20 deletions(-) create mode 100644 TIAMSharedUI/Pages/User/SysAdmins/MessageDetailGridComponent.razor create mode 100644 TIAMSharedUI/Pages/User/SysAdmins/MessageGridComponent.razor diff --git a/TIAMSharedUI/Pages/EditTransfers.razor b/TIAMSharedUI/Pages/EditTransfers.razor index 1aa79188..f5a29181 100644 --- a/TIAMSharedUI/Pages/EditTransfers.razor +++ b/TIAMSharedUI/Pages/EditTransfers.razor @@ -1,16 +1,22 @@ @page "/mytransfers/{transferId:guid}" @using TIAM.Entities.Transfers +@using TIAM.Resources @using TIAMWebApp.Shared.Application.Interfaces @using AyCode.Services.Loggers @using TIAM.Core.Enums +@using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels @using TIAMWebApp.Shared.Application.Services @using TIAMWebApp.Shared.Application.Utility +@using TIAMSharedUI.Pages.User.SysAdmins +@using TIAMSharedUI.Pages.Components @inject HttpClient Http @inject NavigationManager navManager @inject IEnumerable LogWriters @inject ITransferDataService transferDataService @inject SumupService SumUpService @inject NavigationManager navigationManager +@inject IStringLocalizer localizer +@inject IWizardProcessor wizardProcessor Transfer details
@@ -18,6 +24,32 @@

Manage your transfer here

+ + + + + + + + + @if (isLoading) {
@@ -33,7 +65,10 @@ else if (!string.IsNullOrEmpty(errorMessage)) } else { -
+
+ + + @if (!editMode) { @@ -203,6 +238,12 @@ else } + + + + + +
} @@ -216,9 +257,82 @@ else private LoggerClient _logger; + private MessageWizardModel _messageWizardModel = new(); + + private bool _popupVisible; + private bool _autoCollapseDetailRow; + + + public List IgnoreList = + [ + "ReceiverEmailAddress", + "ReceiverFullName", + "ReceiverId", + "SenderEmailAddress", + "SenderFullName", + "SenderId", + "ContextId", + ]; + List StatusTypes = new List(); private bool editMode = false; + void SendMail(Transfer item) + { + _logger.Info($"Sending mail to {item.ContactEmail}, {item.Id}"); + + _messageWizardModel.ReceiverId = item.UserId; + _messageWizardModel.ContextId = item.Id; + _messageWizardModel.SenderEmailAddress = "info@touriam.com"; + _messageWizardModel.ReceiverEmailAddress = item.ContactEmail; + _messageWizardModel.ReceiverFullName = item.FullName; + _popupVisible = true; + } + + void CancelCreateClick() + { + + _popupVisible = false; + } + + void EulaPopupClosed() + { + //cancel clicked + + } + + void EulaPopupClosing(PopupClosingEventArgs args) + { + //myModel = new TransferWizardModel(); + _messageWizardModel = new MessageWizardModel(); + } + + public async Task SubmitForm(object result) + { + var messageModel = result as MessageWizardModel; + messageModel.ContextId = _messageWizardModel.ContextId; + //messageModel.SenderId = sessionService.User.UserId; + + string FormatEmailContent() + { + return $@" + + +

Dear {messageModel.SenderFullName},

+

{messageModel.Content}:

+

Best regards,
Tour I Am team

+ + "; + } + + messageModel.Content = FormatEmailContent(); + + _logger.Info(messageModel.Content); + var email = await wizardProcessor.ProcessWizardAsync(result.GetType(), messageModel); + + _logger.Info($"Submitted nested form: {result.GetType().FullName}"); + } + private async Task Pay() { if (transfer != null) diff --git a/TIAMSharedUI/Pages/User/SysAdmins/ManageTransfers.razor b/TIAMSharedUI/Pages/User/SysAdmins/ManageTransfers.razor index 842507d3..642b1107 100644 --- a/TIAMSharedUI/Pages/User/SysAdmins/ManageTransfers.razor +++ b/TIAMSharedUI/Pages/User/SysAdmins/ManageTransfers.razor @@ -1,6 +1,7 @@ @page "/user/transfers" @using BlazorAnimation @using TIAM.Core.Enums +@using TIAM.Entities.Emails @using TIAM.Entities.Transfers @using TIAM.Resources @using TIAMSharedUI.Pages.Components @@ -150,26 +151,11 @@ - - - - - - - - - - - - - + + diff --git a/TIAMSharedUI/Pages/User/SysAdmins/MessageDetailGridComponent.razor b/TIAMSharedUI/Pages/User/SysAdmins/MessageDetailGridComponent.razor new file mode 100644 index 00000000..64932a3d --- /dev/null +++ b/TIAMSharedUI/Pages/User/SysAdmins/MessageDetailGridComponent.razor @@ -0,0 +1,67 @@ +@using AyCode.Core +@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 TIAMWebApp.Shared.Application.Interfaces +@using TIAMWebApp.Shared.Application.Utility +@using AyCode.Services.Loggers +@using TIAM.Core.Loggers +@using TIAM.Entities.Addresses +@using TIAMSharedUI.Shared.Components.Grids +@using TIAMSharedUI.Pages.Components.EditComponents +@using TIAMWebApp.Shared.Application.Services +@using AyCode.Interfaces.Addresses +@inject IServiceProviderDataService serviceProviderDataService +@inject IUserDataService userDataService +@inject ITransferDataService transferDataService +@inject IEnumerable LogWriters +@inject AdminSignalRClient AdminSignalRClient; + + + + + + + + + + + + @{ + var keyField = (string)messageContext.Value; + } +
@((MarkupString)keyField)
+
+
+ +
+ +
+ +@code { + [Parameter] public bool KeyboardNavigationEnabled { get; set; } + [Parameter] public Guid? ContextId { get; set; } + [Parameter] public bool IsSubjectVisible { get; set; } = true; + [Parameter] public bool IsSenderEmailVisible { get; set; } = true; + + + private Guid? _contextId = null!; + private MessageGrid _messageGrid = null!; + private LoggerClient _logger = null!; + + protected override void OnInitialized() + { + _logger = new LoggerClient(LogWriters.ToArray()); + + //DataSource = new List
(); + + } + +} diff --git a/TIAMSharedUI/Pages/User/SysAdmins/MessageGridComponent.razor b/TIAMSharedUI/Pages/User/SysAdmins/MessageGridComponent.razor new file mode 100644 index 00000000..4bdc72b1 --- /dev/null +++ b/TIAMSharedUI/Pages/User/SysAdmins/MessageGridComponent.razor @@ -0,0 +1,65 @@ +@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 TIAMWebApp.Shared.Application.Interfaces +@using TIAMWebApp.Shared.Application.Utility +@using AyCode.Services.Loggers +@using TIAM.Core.Loggers +@using TIAM.Entities.Addresses +@using TIAMSharedUI.Shared.Components.Grids +@using TIAMSharedUI.Pages.Components.EditComponents +@using TIAMWebApp.Shared.Application.Services +@using AyCode.Interfaces.Addresses +@inject IServiceProviderDataService serviceProviderDataService +@inject IUserDataService userDataService +@inject ITransferDataService transferDataService +@inject IEnumerable LogWriters +@inject AdminSignalRClient AdminSignalRClient; + + + + + + + + + + + + + + + + + +@code { + [Parameter] public bool KeyboardNavigationEnabled { get; set; } + + + private Guid? _contextId = null!; + private MessageGrid _messageGrid = null!; + private LoggerClient _logger = null!; + + protected override void OnInitialized() + { + _logger = new LoggerClient(LogWriters.ToArray()); + + //DataSource = new List
(); + + } + +} \ No newline at end of file diff --git a/TIAMWebApp/Server/Controllers/TransferDataAPIController.cs b/TIAMWebApp/Server/Controllers/TransferDataAPIController.cs index 433356f9..2ece8fd4 100644 --- a/TIAMWebApp/Server/Controllers/TransferDataAPIController.cs +++ b/TIAMWebApp/Server/Controllers/TransferDataAPIController.cs @@ -267,7 +267,7 @@ namespace TIAMWebApp.Server.Controllers

{transfer.FullName}

{transfer.PassengerCount}

Please confirm the transfer by clicking on the following link:

-

Confirm Transfer

+

Confirm Transfer

If you did not request this transfer, please disregard this email.

Thank you,
Tour I Am team

@@ -356,7 +356,7 @@ namespace TIAMWebApp.Server.Controllers

{createdTransfer.FullName}

{createdTransfer.PassengerCount}

Please confirm the transfer by clicking on the following link:

-

Confirm Transfer

+

Confirm Transfer

If you did not request this transfer, please disregard this email.

Thank you,
Tour I Am team

From 3116489d3dc5ae28aef949245eb3f43bef230b33 Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 21 Jun 2024 14:31:34 +0200 Subject: [PATCH 2/2] Merge 2 --- TIAM.Database/DataLayers/Admins/AdminDal.cs | 10 +- TIAM.Services/SignalRTags.cs | 11 +- .../Pages/User/Hotels/HotelAdmin.razor | 8 +- .../Pages/User/Hotels/HotelComponent.razor | 2 + TIAMSharedUI/Pages/User/ServiceProvider.razor | 137 +++++++++++++++-- .../SysAdmins/ManageServiceProviders.razor | 41 ++--- .../User/SysAdmins/ManageTransfers.razor | 27 +--- .../Pages/User/SysAdmins/ManageUsers.razor | 17 ++- .../ProductDetailGridComponent.razor | 142 ++++++++++++++++++ .../User/SysAdmins/ProfileGridComponent.razor | 104 ++++++------- .../ServiceProviderGridComponent.razor | 127 ++++++++-------- .../Components/Grids/CompanyDetailGrid.cs | 9 ++ .../Components/Grids/ProductDetailGrid.cs | 30 ++++ .../Shared/Components/Grids/ProductGrid.cs | 30 ++++ .../Components/Grids/ProfileDetailGrid.cs | 24 +++ .../Shared/Components/Grids/ProfileGrid.cs | 30 ++++ .../Controllers/ProfileAPIController.cs | 69 +++++++++ .../ServiceProviderAPIController.cs | 87 ++++++++--- TIAMWebApp/Server/Program.cs | 1 + .../Server/Services/DevAdminSignalRhub.cs | 3 +- .../Interfaces/IServiceProviderDataService.cs | 2 +- TIAMWebApp/Shared/Models/APIUrls.cs | 12 +- .../Services/ServiceProviderDataService.cs | 35 ++++- 23 files changed, 735 insertions(+), 223 deletions(-) create mode 100644 TIAMSharedUI/Pages/User/SysAdmins/ProductDetailGridComponent.razor create mode 100644 TIAMSharedUI/Shared/Components/Grids/ProductDetailGrid.cs create mode 100644 TIAMSharedUI/Shared/Components/Grids/ProductGrid.cs create mode 100644 TIAMSharedUI/Shared/Components/Grids/ProfileDetailGrid.cs create mode 100644 TIAMSharedUI/Shared/Components/Grids/ProfileGrid.cs create mode 100644 TIAMWebApp/Server/Controllers/ProfileAPIController.cs diff --git a/TIAM.Database/DataLayers/Admins/AdminDal.cs b/TIAM.Database/DataLayers/Admins/AdminDal.cs index 61b7fea7..206192a2 100644 --- a/TIAM.Database/DataLayers/Admins/AdminDal.cs +++ b/TIAM.Database/DataLayers/Admins/AdminDal.cs @@ -187,7 +187,7 @@ namespace TIAM.Database.DataLayers.Admins #endregion Address #region Profile - public Task GetProfileByIdAsync(Guid addressId) => SessionAsync(ctx => ctx.GetProfileById(addressId)); + public Task GetProfileByIdAsync(Guid profileId) => SessionAsync(ctx => ctx.GetProfileById(profileId)); public Task UpdateProfileAsync(Profile profile) => TransactionAsync(ctx => ctx.UpdateProfile(profile)); //public Task AddProfileAsync(Profile profile) => TransactionAsync(ctx => ctx.AddProfile(profile)); //Nem Add-olunk önmagában Profile-t! - J. //public Task 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 GetServiceProviderByIdAsync(Guid id) => SessionAsync(ctx => ctx.GetServiceProviderById(id)); + public virtual Task> GetServiceProvidersByOwnerIdAsync(Guid id) => SessionAsync(ctx => ctx.GetServiceProvidersByOwnerId(id)); //public Task CreateUserProductMappingAsync(UserProductMapping userProductMapping) //{ @@ -252,13 +253,6 @@ namespace TIAM.Database.DataLayers.Admins public Task RemoveCompanyAsync(Company company) => TransactionAsync(ctx => ctx.RemoveServiceProvider(company)); - //17. (IServiceProviderDataService) get service provider by ownerId - public Task> GetServiceProvidersByOwnerIdAsync() - { - throw new NotImplementedException(); - - } - #endregion #region PermissionTypes diff --git a/TIAM.Services/SignalRTags.cs b/TIAM.Services/SignalRTags.cs index 684bfbd6..bcc97aa2 100644 --- a/TIAM.Services/SignalRTags.cs +++ b/TIAM.Services/SignalRTags.cs @@ -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; } diff --git a/TIAMSharedUI/Pages/User/Hotels/HotelAdmin.razor b/TIAMSharedUI/Pages/User/Hotels/HotelAdmin.razor index b5b780ab..f5577435 100644 --- a/TIAMSharedUI/Pages/User/Hotels/HotelAdmin.razor +++ b/TIAMSharedUI/Pages/User/Hotels/HotelAdmin.razor @@ -5,7 +5,7 @@ @inject IPopulationStructureDataProvider DataProvider @inject ISupplierService SupplierService @inject IUserDataService UserDataService -Transfer +HotelAdmin

Dashboard

@@ -17,12 +17,12 @@
- +
-
+ @*
@@ -177,7 +177,7 @@
-
+
*@
diff --git a/TIAMSharedUI/Pages/User/Hotels/HotelComponent.razor b/TIAMSharedUI/Pages/User/Hotels/HotelComponent.razor index 7f36f7d8..4e6afd75 100644 --- a/TIAMSharedUI/Pages/User/Hotels/HotelComponent.razor +++ b/TIAMSharedUI/Pages/User/Hotels/HotelComponent.razor @@ -6,6 +6,8 @@ + +
diff --git a/TIAMSharedUI/Pages/User/ServiceProvider.razor b/TIAMSharedUI/Pages/User/ServiceProvider.razor index c39b1bda..0aeb47f1 100644 --- a/TIAMSharedUI/Pages/User/ServiceProvider.razor +++ b/TIAMSharedUI/Pages/User/ServiceProvider.razor @@ -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 LogWriters +@inject IStringLocalizer localizer +@inject IServiceProviderDataService serviceProviderDataService +@inject IUserDataService userDataService +@inject ISessionService sessionService +@inject AdminSignalRClient AdminSignalRClient; +Admin - Companies

Company: @Id

@@ -10,18 +26,78 @@
+ + + + + + + + + + + + @* + + *@ + + + @* + + *@ + + + + + + + + + + + + + + + @{ + var transfer2 = (Company)EditFormContext.EditModel; + } + + + @EditFormContext.GetEditor("Name") + + + @EditFormContext.GetEditor("CommissionPercent") + + + + + - - - - - - + @* + + *@ + @* + + *@ + + - - - - + @* + + *@
@@ -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 _logger; + protected override void OnInitialized() { base.OnInitialized(); + _logger = new LoggerClient(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(); + } } } diff --git a/TIAMSharedUI/Pages/User/SysAdmins/ManageServiceProviders.razor b/TIAMSharedUI/Pages/User/SysAdmins/ManageServiceProviders.razor index 18247ea6..acad2fd0 100644 --- a/TIAMSharedUI/Pages/User/SysAdmins/ManageServiceProviders.razor +++ b/TIAMSharedUI/Pages/User/SysAdmins/ManageServiceProviders.razor @@ -43,7 +43,7 @@ - + @* *@ @@ -125,7 +125,17 @@ *@ - + + + + + + + + + + + @{ @@ -163,6 +173,8 @@ private CompanyGrid _gridCompany; private bool _autoCollapseDetailRow; + private Company CompanyToSetOwner = null; + public List IgnoreList = [ "ReceiverEmailAddress", @@ -179,15 +191,7 @@ string EmailMask { get; set; } = @"(\w|[.-])+@(\w|-)+\.(\w|-){2,4}"; 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; - } + DxSchedulerDataStorage _dataStorage = new(); void SendMail(Company item) { @@ -203,26 +207,27 @@ void SetOwnerPopup(Company item) { _logger.Info($"Setting owner of {item.OwnerId}, {item.Id}"); - + CompanyToSetOwner = item; _setOwnerPopupVisible = true; } - async Task SetOwner(Guid CompanyId) + async Task 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; } } diff --git a/TIAMSharedUI/Pages/User/SysAdmins/ManageTransfers.razor b/TIAMSharedUI/Pages/User/SysAdmins/ManageTransfers.razor index c19e7045..37294fe6 100644 --- a/TIAMSharedUI/Pages/User/SysAdmins/ManageTransfers.razor +++ b/TIAMSharedUI/Pages/User/SysAdmins/ManageTransfers.razor @@ -153,32 +153,7 @@ - - - - - - - - - - - @System.Text.RegularExpressions.Regex.Replace((displayTextContext.Value as string)!, "<(.|\n)*?>", string.Empty) - - - - @{ - var value = ((EmailMessage)editTextContext.EditModel).Text; - - } - - - - - + diff --git a/TIAMSharedUI/Pages/User/SysAdmins/ManageUsers.razor b/TIAMSharedUI/Pages/User/SysAdmins/ManageUsers.razor index 47a17fed..be3abb06 100644 --- a/TIAMSharedUI/Pages/User/SysAdmins/ManageUsers.razor +++ b/TIAMSharedUI/Pages/User/SysAdmins/ManageUsers.razor @@ -29,8 +29,8 @@ CloseOnOutsideClick="false" ShowCloseButton="false" HeaderText="MessageBox" - Closing="EulaPopupClosing" - Closed="EulaPopupClosed"> + Closing="EmailPopupClosing" + Closed="EmailPopupClosed"> - + @@ -89,18 +89,21 @@ var keyItem = (UserModelDtoDetail)context.DataItem; var buttonText = "Contact"; - +

@keyField

}
+ + + - + @@ -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(); diff --git a/TIAMSharedUI/Pages/User/SysAdmins/ProductDetailGridComponent.razor b/TIAMSharedUI/Pages/User/SysAdmins/ProductDetailGridComponent.razor new file mode 100644 index 00000000..55753700 --- /dev/null +++ b/TIAMSharedUI/Pages/User/SysAdmins/ProductDetailGridComponent.razor @@ -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 Localizer +@inject IServiceProviderDataService serviceProviderDataService +@inject IUserDataService userDataService +@inject ITransferDataService transferDataService +@inject IEnumerable LogWriters +@inject AdminSignalRClient AdminSignalRClient; + + + + + + + + + + + + + + + + + + + + + @{ + var transfer2 = (Product)EditFormContext.EditModel; + } + + + @EditFormContext.GetEditor("Name") + + + @EditFormContext.GetEditor("ProductType") + + + @EditFormContext.GetEditor("Price") + + + @EditFormContext.GetEditor("Description") + + + + + + + + +@code { + [Parameter] public bool KeyboardNavigationEnabled { get; set; } + [Parameter] public Guid? ContextId { get; set; } + + private ProductDetailGrid _productGrid = null!; + private LoggerClient _logger = null!; + protected override void OnInitialized() + { + _logger = new LoggerClient(LogWriters.ToArray()); + + //DataSource = new List
(); + + } + + private void DataItemChanged(GridDataItemChangedEventArgs 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"; + } + +} \ No newline at end of file diff --git a/TIAMSharedUI/Pages/User/SysAdmins/ProfileGridComponent.razor b/TIAMSharedUI/Pages/User/SysAdmins/ProfileGridComponent.razor index 9250f1d7..5d93ea52 100644 --- a/TIAMSharedUI/Pages/User/SysAdmins/ProfileGridComponent.razor +++ b/TIAMSharedUI/Pages/User/SysAdmins/ProfileGridComponent.razor @@ -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 LogWriters - -
-

Profile

-
- +@inject AdminSignalRClient AdminSignalRClient + - + - - - + + + + - + + + + + + + + - + + + + @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 _detailGridData; - - List _availableProfiles; - - ILogger _logger; + private ProfileDetailGrid _profileGrid = null!; + private LoggerClient _logger = null!; protected override async Task OnInitializedAsync() - { + { + _logger = new LoggerClient(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"); diff --git a/TIAMSharedUI/Pages/User/SysAdmins/ServiceProviderGridComponent.razor b/TIAMSharedUI/Pages/User/SysAdmins/ServiceProviderGridComponent.razor index 54fd580e..0b760ae3 100644 --- a/TIAMSharedUI/Pages/User/SysAdmins/ServiceProviderGridComponent.razor +++ b/TIAMSharedUI/Pages/User/SysAdmins/ServiceProviderGridComponent.razor @@ -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 LogWriters +@inject AdminSignalRClient AdminSignalRClient; -
-

Companies owned

-
- - - - + + + + + + + + + + + + + + + @{ - var transfer2 = (UserProductMapping)EditFormContext.EditModel; + var serviceProvider = (Company)EditFormContext.EditModel; } - - @EditFormContext.GetEditor("UserId") + + @EditFormContext.GetEditor("Name") - - - - - @EditFormContext.GetEditor("Permissions") + + + @EditFormContext.GetEditor("CommissionPercent") @@ -54,13 +64,12 @@ - + @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 _detailGridData; @@ -68,54 +77,54 @@ public UserModelDtoDetail UserInfo; - ILogger _logger; + private LoggerClient _logger = null!; protected override async Task OnInitializedAsync() { _logger = new LoggerClient(LogWriters.ToArray()); - _detailGridData = UserModelDtoDetail.ServiceProviders ?? new List(); - _availableServices = await ServiceProviderDataService.GetServiceProvidersAsync(); + //_detailGridData = UserModelDtoDetail.ServiceProviders ?? new List(); + //_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(); - } + // await UpdateDataAsync(); + // } - async Task DataItemDeleting(GridDataItemDeletingEventArgs e) - { - //remove orderData from orderData array - _logger.Info("orderData deleted"); - //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 UpdateDataAsync() + // { + // //refresh grid + // _logger.Info("orderData grid refreshed"); + // } } \ No newline at end of file diff --git a/TIAMSharedUI/Shared/Components/Grids/CompanyDetailGrid.cs b/TIAMSharedUI/Shared/Components/Grids/CompanyDetailGrid.cs index 7e3d2de8..4ef81ab8 100644 --- a/TIAMSharedUI/Shared/Components/Grids/CompanyDetailGrid.cs +++ b/TIAMSharedUI/Shared/Components/Grids/CompanyDetailGrid.cs @@ -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; diff --git a/TIAMSharedUI/Shared/Components/Grids/ProductDetailGrid.cs b/TIAMSharedUI/Shared/Components/Grids/ProductDetailGrid.cs new file mode 100644 index 00000000..643709a7 --- /dev/null +++ b/TIAMSharedUI/Shared/Components/Grids/ProductDetailGrid.cs @@ -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); + } +} \ No newline at end of file diff --git a/TIAMSharedUI/Shared/Components/Grids/ProductGrid.cs b/TIAMSharedUI/Shared/Components/Grids/ProductGrid.cs new file mode 100644 index 00000000..9bdb43b4 --- /dev/null +++ b/TIAMSharedUI/Shared/Components/Grids/ProductGrid.cs @@ -0,0 +1,30 @@ +using Microsoft.AspNetCore.Components; +using TIAM.Entities.Products; +using TIAM.Services; + +namespace TIAMSharedUI.Shared.Components.Grids; + +public class ProductGrid : TiamGrid +{ + 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); + } +} \ No newline at end of file diff --git a/TIAMSharedUI/Shared/Components/Grids/ProfileDetailGrid.cs b/TIAMSharedUI/Shared/Components/Grids/ProfileDetailGrid.cs new file mode 100644 index 00000000..8e438c7f --- /dev/null +++ b/TIAMSharedUI/Shared/Components/Grids/ProfileDetailGrid.cs @@ -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); + } +} \ No newline at end of file diff --git a/TIAMSharedUI/Shared/Components/Grids/ProfileGrid.cs b/TIAMSharedUI/Shared/Components/Grids/ProfileGrid.cs new file mode 100644 index 00000000..3da936b3 --- /dev/null +++ b/TIAMSharedUI/Shared/Components/Grids/ProfileGrid.cs @@ -0,0 +1,30 @@ +using Microsoft.AspNetCore.Components; +using TIAM.Entities.Profiles; +using TIAM.Services; + +namespace TIAMSharedUI.Shared.Components.Grids; + +public class ProfileGrid : TiamGrid +{ + 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); + } +} \ No newline at end of file diff --git a/TIAMWebApp/Server/Controllers/ProfileAPIController.cs b/TIAMWebApp/Server/Controllers/ProfileAPIController.cs new file mode 100644 index 00000000..4312a705 --- /dev/null +++ b/TIAMWebApp/Server/Controllers/ProfileAPIController.cs @@ -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 logWriters) : ControllerBase + { + private readonly TIAM.Core.Loggers.Logger _logger = new(logWriters.ToArray()); + + + [AllowAnonymous] + [HttpGet] + [Route(APIUrls.GetProfileByIdRouteName)] + [SignalR(SignalRTags.GetProfileById)] + public async Task GetProfileById([FromBody] Guid id) + { + if (id != Guid.Empty) + { + _logger.Info($@"GetServiceProviderById called with id: {id}"); + var result = await adminDal.GetProfileByIdAsync(id); + List profiles = new List(); + 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 UpdateProfile(Profile profile) + { + _logger.Info($"UpdateUserProductMapping called! + {profile.Id}"); + + var result = await adminDal.UpdateProfileAsync(profile); + + return result ? profile.ToJson() : string.Empty; + } + + + } +} \ No newline at end of file diff --git a/TIAMWebApp/Server/Controllers/ServiceProviderAPIController.cs b/TIAMWebApp/Server/Controllers/ServiceProviderAPIController.cs index f1f8419d..bca3c490 100644 --- a/TIAMWebApp/Server/Controllers/ServiceProviderAPIController.cs +++ b/TIAMWebApp/Server/Controllers/ServiceProviderAPIController.cs @@ -63,7 +63,7 @@ namespace TIAMWebApp.Server.Controllers throw new ArgumentOutOfRangeException(nameof(trackingState), trackingState, null); } } - + [NonAction] [ApiExplorerSettings(IgnoreApi = true)] [SignalR(SignalRTags.AddCompany)] @@ -103,7 +103,7 @@ namespace TIAMWebApp.Server.Controllers [Route(APIUrls.GetServiceProvidersRouteName)] [SignalR(SignalRTags.GetCompanies)] public async Task GetServiceProviders() - { + { return await adminDal.GetServiceProvidersJsonAsync(); } @@ -138,16 +138,34 @@ namespace TIAMWebApp.Server.Controllers return myServiceproviders; } + [Authorize] + [HttpPost] + [Route(APIUrls.GetCompaniesByContextIdRouteName)] + [Tags("Finished", "ServiceProvider")] + [SignalR(SignalRTags.GetCompaniesByContextId)] + public async Task 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] - [Route(APIUrls.CreateUserProductMappingRouteName)] + [Route(APIUrls.CreateUserProductMappingRouteName)] [Tags("Finished", "ServiceProvider")] [EndpointSummary("Create assigned user to product")] [SignalR(SignalRTags.CreateUserProductMapping)] public async Task CreateUserProductMapping(UserProductMapping userProductMapping) { - if(userProductMapping.ProductId == Guid.Empty || userProductMapping.UserId == Guid.Empty) + if (userProductMapping.ProductId == Guid.Empty || userProductMapping.UserId == Guid.Empty) { return BadRequest("Invalid request"); } @@ -190,7 +208,7 @@ namespace TIAMWebApp.Server.Controllers //23. [AllowAnonymous] [HttpPost] - [Route(APIUrls.GetUserProductMappingsForProductRouteName)] + [Route(APIUrls.GetUserProductMappingsForProductRouteName)] public async Task> GetUserProductMappingsForProduct(Guid serviceProviderId) { _logger.Info($@"GetUserProductMappingsForServiceProvider called with serviceProviderId: {serviceProviderId}"); @@ -203,7 +221,7 @@ namespace TIAMWebApp.Server.Controllers //put serviceprovider id and name into a dictionary return myServiceproviders; - } + } [AllowAnonymous] [HttpGet] @@ -213,7 +231,7 @@ namespace TIAMWebApp.Server.Controllers { _logger.Info($@"GetCarsForUserProductMapping called with userProductMappingId: {userProductMappingId}"); - var cars = adminDal.GetCarByUserProductMappingId(Guid.Parse(userProductMappingId)); + var cars = adminDal.GetCarByUserProductMappingId(Guid.Parse(userProductMappingId)); return cars; } @@ -278,8 +296,10 @@ namespace TIAMWebApp.Server.Controllers [HttpPost] [Route(APIUrls.AddProductRouteName)] [Tags("In-Progress", "Product")] + [SignalR(SignalRTags.AddProduct)] public async Task 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); } } @@ -321,36 +341,55 @@ namespace TIAMWebApp.Server.Controllers var byteImage = ms.ToArray(); var sigBase64 = Convert.ToBase64String(byteImage); // Get Base64 - + return Ok(sigBase64); } } + [NonAction] + [ApiExplorerSettings(IgnoreApi = true)] + public async Task 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)] + [Route(APIUrls.GetProductsByServiceProviderIdRouteName)] [Tags("In-Progress", "Product")] - public IActionResult GetProductsByServiceProviderId([FromBody] Guid serviceProviderId) + [SignalR(SignalRTags.GetProductsByOwnerId)] + public async Task 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; } diff --git a/TIAMWebApp/Server/Program.cs b/TIAMWebApp/Server/Program.cs index 757559a9..3fc8781a 100644 --- a/TIAMWebApp/Server/Program.cs +++ b/TIAMWebApp/Server/Program.cs @@ -41,6 +41,7 @@ builder.Services.AddSingleton(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); +builder.Services.AddScoped(); builder.Services.AddSignalR(options => options.MaximumReceiveMessageSize = 128 * 1024);//.AddMessagePackProtocol(options => options.SerializerOptions = MessagePackSerializerOptions.Standard.WithSecurity(MessagePackSecurity.UntrustedData)); diff --git a/TIAMWebApp/Server/Services/DevAdminSignalRhub.cs b/TIAMWebApp/Server/Services/DevAdminSignalRhub.cs index be9b565f..a0fe6f51 100644 --- a/TIAMWebApp/Server/Services/DevAdminSignalRhub.cs +++ b/TIAMWebApp/Server/Services/DevAdminSignalRhub.cs @@ -90,7 +90,7 @@ public class DevAdminSignalRHub : Hub, IAcSignalRHubServe //private readonly ServiceProviderAPIController _serviceProviderApiController; //private readonly TransferDataAPIController _transferDataApiController; - public DevAdminSignalRHub(AdminDal adminDal, ServiceProviderAPIController serviceProviderApiController, TransferDataAPIController transferDataApiController, MessageAPIController messageApiController, IEnumerable logWriters) + public DevAdminSignalRHub(AdminDal adminDal, ServiceProviderAPIController serviceProviderApiController, TransferDataAPIController transferDataApiController, MessageAPIController messageApiController, ProfileAPIController profileApiController, IEnumerable logWriters) { _adminDal = adminDal; //_serviceProviderApiController = serviceProviderApiController; @@ -101,6 +101,7 @@ public class DevAdminSignalRHub : Hub, IAcSignalRHubServe _dynamicMethodCallModels.Add(new DynamicMethodCallModel(serviceProviderApiController)); _dynamicMethodCallModels.Add(new DynamicMethodCallModel(transferDataApiController)); _dynamicMethodCallModels.Add(new DynamicMethodCallModel(messageApiController)); + _dynamicMethodCallModels.Add(new DynamicMethodCallModel(profileApiController)); //_dynamicMethodCallModels.Add(new DynamicMethodCallModel(typeof(AdminDal))); } diff --git a/TIAMWebApp/Shared/Interfaces/IServiceProviderDataService.cs b/TIAMWebApp/Shared/Interfaces/IServiceProviderDataService.cs index dc488ac3..ba5ea15b 100644 --- a/TIAMWebApp/Shared/Interfaces/IServiceProviderDataService.cs +++ b/TIAMWebApp/Shared/Interfaces/IServiceProviderDataService.cs @@ -26,7 +26,7 @@ namespace TIAMWebApp.Shared.Application.Interfaces public Task GetServiceProviderByIdAsync(Guid id); //19. (IServiceProviderDataService) Create product - public Task CreateProductAsync(Product product); + public Task CreateProductAsync(Product product); //20. (IServiceProviderDataService) Update product public Task UpdateProductAsync(Product product); diff --git a/TIAMWebApp/Shared/Models/APIUrls.cs b/TIAMWebApp/Shared/Models/APIUrls.cs index 33a8ac34..624fb4a0 100644 --- a/TIAMWebApp/Shared/Models/APIUrls.cs +++ b/TIAMWebApp/Shared/Models/APIUrls.cs @@ -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; diff --git a/TIAMWebApp/Shared/Services/ServiceProviderDataService.cs b/TIAMWebApp/Shared/Services/ServiceProviderDataService.cs index 2827e839..c9419006 100644 --- a/TIAMWebApp/Shared/Services/ServiceProviderDataService.cs +++ b/TIAMWebApp/Shared/Services/ServiceProviderDataService.cs @@ -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 CreateProductAsync(Product product) + public async Task 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 GetServiceProviderByIdAsync(Guid id) + public async Task GetServiceProviderByIdAsync(Guid id) { - throw new NotImplementedException(); + var company = await _adminSignalRClient.GetByIdAsync(SignalRTags.GetCompany, id); + if (company != null) _logger.DetailConditional($"company: {company.Name}"); + + return company; } //16.