From fec32f6642152dc22e0ec1c7aea2a07e9cb410ea Mon Sep 17 00:00:00 2001 From: Loretta Date: Mon, 24 Jun 2024 14:00:11 +0200 Subject: [PATCH] improvements, fixes, etc... --- TIAM.Database/DataLayers/Admins/AdminDal.cs | 1 + TIAM.Services/SignalRTags.cs | 9 +- .../SysAdmins/CarDetailGridComponent.razor | 124 +++++----------- .../User/SysAdmins/CarGridComponent.razor | 107 ++++---------- .../User/SysAdmins/DriverGridComponent.razor | 138 +++++++----------- .../Pages/User/SysAdmins/ManageCars.razor | 2 +- .../Pages/User/SysAdmins/ManageDrivers.razor | 2 +- .../SysAdmins/ManageUserProductMappings.razor | 2 +- .../ProductDetailGridComponent.razor | 45 ++---- .../UserProductMappingGridComponent.razor | 79 +++------- .../ServiceProviderAPIController.cs | 38 ++--- 11 files changed, 164 insertions(+), 383 deletions(-) diff --git a/TIAM.Database/DataLayers/Admins/AdminDal.cs b/TIAM.Database/DataLayers/Admins/AdminDal.cs index 06a189e3..a7f74c2b 100644 --- a/TIAM.Database/DataLayers/Admins/AdminDal.cs +++ b/TIAM.Database/DataLayers/Admins/AdminDal.cs @@ -118,6 +118,7 @@ namespace TIAM.Database.DataLayers.Admins public Task RemoveUserAsync(Guid userId) => TransactionAsync(ctx => ctx.RemoveUser(userId)); public Product? GetProductById(Guid contextId, bool includeUsers = true) => Session(ctx => ctx.GetProductById(contextId, includeUsers)); + public Task GetProductByIdAsync(Guid contextId, bool includeUsers = true) => SessionAsync(ctx => ctx.GetProductById(contextId, includeUsers)); public string GetProductsJson(bool includeUsers = true) => Session(ctx => ctx.ProductsWithUserRelations(includeUsers).ToJson()); public List GetProductsByServiceProviderId(Guid serviceProviderId, bool includeUsers = true) => Session(ctx => ctx.GetProductsByCompanyId(serviceProviderId, includeUsers).ToList()); diff --git a/TIAM.Services/SignalRTags.cs b/TIAM.Services/SignalRTags.cs index 7e15e654..fe95c0bd 100644 --- a/TIAM.Services/SignalRTags.cs +++ b/TIAM.Services/SignalRTags.cs @@ -19,10 +19,11 @@ public class SignalRTags : AcSignalRTags public const int GetCompany = 12; public const int GetCompanies = 13; - public const int GetCompaniesByContextId = 14; - public const int UpdateCompany = 15; - public const int AddCompany = 16; - public const int RemoveCompany = 17; + public const int GetCompaniesById = 14; + public const int GetCompaniesByContextId = 15; + public const int UpdateCompany = 16; + public const int AddCompany = 17; + public const int RemoveCompany = 18; public const int GetTransferToDriver = 22; //public const int GetTransferToDrivers = 23; diff --git a/TIAMSharedUI/Pages/User/SysAdmins/CarDetailGridComponent.razor b/TIAMSharedUI/Pages/User/SysAdmins/CarDetailGridComponent.razor index 0da339c5..59c3442d 100644 --- a/TIAMSharedUI/Pages/User/SysAdmins/CarDetailGridComponent.razor +++ b/TIAMSharedUI/Pages/User/SysAdmins/CarDetailGridComponent.razor @@ -18,7 +18,7 @@ - - + + @@ -45,88 +46,65 @@ @{ - if (ShowNestedRows) - { - + - - - + + + - - } + } - + @{ - var car = (Car)UserEditFormContext.EditModel; + var car = (Car)userEditFormContext.EditModel; } - @UserEditFormContext.GetEditor("CountryCode") + @userEditFormContext.GetEditor("CountryCode") - @UserEditFormContext.GetEditor("LicencePlate") + @userEditFormContext.GetEditor("LicencePlate") - @UserEditFormContext.GetEditor("Color") + @userEditFormContext.GetEditor("Color") - @UserEditFormContext.GetEditor("Manufacture") + @userEditFormContext.GetEditor("Manufacture") - @UserEditFormContext.GetEditor("CarModel") + @userEditFormContext.GetEditor("CarModel") - @UserEditFormContext.GetEditor("YearOfMake") + @userEditFormContext.GetEditor("YearOfMake") - @UserEditFormContext.GetEditor("SeatNumber") + @userEditFormContext.GetEditor("SeatNumber") - @UserEditFormContext.GetEditor("CarMotorType") + @userEditFormContext.GetEditor("CarMotorType") - - @code { - [Parameter] - public bool KeyboardNavigationEnabled { get; set; } - + [Parameter] public Guid ContextId { get; set; } + [Parameter] public bool KeyboardNavigationEnabled { get; set; } [Parameter] public ICarRelation ParentData { get; set; } = null!; - [Parameter] public int GetAllTag { get; set; } = SignalRTags.GetAllCars; + [Parameter] public GridDetailExpandButtonDisplayMode DetailExpandButtonDisplayMode { get; set; } = GridDetailExpandButtonDisplayMode.Never; - [Parameter] public bool ShowNestedRows { get; set; } = false; + private LoggerClient _logger = null!; - [Parameter] public Guid? ContextId { get; set; } - - private Guid[] ContextIds = new Guid[0]; - - private LoggerClient _logger; - - protected override void OnParametersSet() - { - if (ContextId != null) - { - ContextIds = new Guid[1]; - ContextIds[0] = (Guid)ContextId; - } - base.OnParametersSet(); - } - - protected override async Task OnInitializedAsync() + protected override void OnInitialized() { _logger = new LoggerClient(LogWriters.ToArray()); - - //_logger.Info($"DetailGridData: {_detailGridData.Count}"); + base.OnInitialized(); } void CustomizeEditModel(GridCustomizeEditModelEventArgs e) @@ -134,53 +112,25 @@ if (e.IsNew) { var newCar = new Car - { - Id = Guid.NewGuid(), - UserProductMappingId = (Guid)ContextId, - CountryCode = 1, - LicencePlate = "ABC123", - Color = "White", - Manufacture = "Manufacturer", - CarModel = "Car model", - YearOfMake = DateTime.Now.Year, - SeatNumber = 5, - CarMotorType = TIAM.Core.Enums.CarMotorType.Electric - }; + { + Id = Guid.NewGuid(), + UserProductMappingId = ContextId!, + CountryCode = 1, + LicencePlate = "ABC123", + Color = "White", + Manufacture = "Manufacturer", + CarModel = "Car model", + YearOfMake = DateTime.Now.Year, + SeatNumber = 5, + CarMotorType = TIAM.Core.Enums.CarMotorType.Electric + }; e.EditModel = newCar; } - else { // } - - - } - - - async Task EditModelSaving(GridEditModelSavingEventArgs e) - { - if (e.IsNew) - - _logger.Info("New orderData added"); - else - _logger.Info("orderData updated"); - - await UpdateDataAsync(); - } - - async Task DataItemDeleting(GridDataItemDeletingEventArgs e) - { - - _logger.Info("orderData deleted"); - - } - - async Task UpdateDataAsync() - { - //refresh grid - _logger.Info("orderData grid refreshed"); } } \ No newline at end of file diff --git a/TIAMSharedUI/Pages/User/SysAdmins/CarGridComponent.razor b/TIAMSharedUI/Pages/User/SysAdmins/CarGridComponent.razor index 3c1ad166..c944fca3 100644 --- a/TIAMSharedUI/Pages/User/SysAdmins/CarGridComponent.razor +++ b/TIAMSharedUI/Pages/User/SysAdmins/CarGridComponent.razor @@ -18,7 +18,7 @@ - - + + @@ -45,127 +46,69 @@ @{ - if (ShowNestedRows) - { - + - - - + + + - - } + } - + @{ - var car = (Car)UserEditFormContext.EditModel; + var car = (Car)userEditFormContext.EditModel; } - @UserEditFormContext.GetEditor("CountryCode") + @userEditFormContext.GetEditor("CountryCode") - @UserEditFormContext.GetEditor("LicencePlate") + @userEditFormContext.GetEditor("LicencePlate") - @UserEditFormContext.GetEditor("Color") + @userEditFormContext.GetEditor("Color") - @UserEditFormContext.GetEditor("Manufacture") + @userEditFormContext.GetEditor("Manufacture") - @UserEditFormContext.GetEditor("CarModel") + @userEditFormContext.GetEditor("CarModel") - @UserEditFormContext.GetEditor("YearOfMake") + @userEditFormContext.GetEditor("YearOfMake") - @UserEditFormContext.GetEditor("SeatNumber") + @userEditFormContext.GetEditor("SeatNumber") - @UserEditFormContext.GetEditor("CarMotorType") + @userEditFormContext.GetEditor("CarMotorType") - - - @code { - [Parameter] - public bool KeyboardNavigationEnabled { get; set; } - + [Parameter] public Guid ContextId { get; set; } + [Parameter] public bool KeyboardNavigationEnabled { get; set; } [Parameter] public ICarRelation ParentData { get; set; } = null!; - [Parameter] public int GetAllTag { get; set; } = SignalRTags.GetAllCars; + [Parameter] public GridDetailExpandButtonDisplayMode DetailExpandButtonDisplayMode { get; set; } = GridDetailExpandButtonDisplayMode.Never; - [Parameter] public bool ShowNestedRows { get; set; } = false; + private LoggerClient _logger = null!; - [Parameter] public Guid? ContextId { get; set; } - - private Guid[] ContextIds = new Guid[0]; - - private LoggerClient _logger; - - protected override void OnParametersSet() - { - if (ContextId != null) - { - ContextIds = new Guid[1]; - ContextIds[0] = (Guid)ContextId; - } - base.OnParametersSet(); - } - - protected override async Task OnInitializedAsync() + protected override void OnInitialized() { _logger = new LoggerClient(LogWriters.ToArray()); - - //_logger.Info($"DetailGridData: {_detailGridData.Count}"); + base.OnInitialized(); } void CustomizeEditModel(GridCustomizeEditModelEventArgs e) { if (!e.IsNew) return; - - // var newProductMapping = new UserProductMapping - // { - // ProductId = Guid.NewGuid(), - // UserId = UserModelDtoDetail.Id, - // Permissions = 1 - // }; - - //e.EditModel = newProductMapping; - } - - - async Task EditModelSaving(GridEditModelSavingEventArgs e) - { - if (e.IsNew) - - _logger.Info("New orderData added"); - else - _logger.Info("orderData updated"); - - await UpdateDataAsync(); - } - - async Task DataItemDeleting(GridDataItemDeletingEventArgs e) - { - - _logger.Info("orderData deleted"); - - } - - async Task UpdateDataAsync() - { - //refresh grid - _logger.Info("orderData grid refreshed"); } } \ No newline at end of file diff --git a/TIAMSharedUI/Pages/User/SysAdmins/DriverGridComponent.razor b/TIAMSharedUI/Pages/User/SysAdmins/DriverGridComponent.razor index 86ce0ae8..73cc62ca 100644 --- a/TIAMSharedUI/Pages/User/SysAdmins/DriverGridComponent.razor +++ b/TIAMSharedUI/Pages/User/SysAdmins/DriverGridComponent.razor @@ -12,6 +12,7 @@ @using AyCode.Core.Loggers @using AyCode.Services.Loggers @using AyCode.Core +@using AyCode.Core.Extensions @inject IServiceProviderDataService ServiceProviderDataService @inject IEnumerable LogWriters @inject AdminSignalRClient AdminSignalRClient @@ -31,14 +32,14 @@ - - -

User not found, type another email please

+ +

User not found, type another email please

@@ -54,9 +55,10 @@ + - - + + @{ - if (ShowNestedRows) - { @@ -89,7 +90,6 @@ - } } @@ -122,114 +122,76 @@ @code { - [Parameter] - public bool KeyboardNavigationEnabled { get; set; } - + [Parameter] public Guid ContextId { get; set; } + [Parameter] public bool KeyboardNavigationEnabled { get; set; } [Parameter] public IProductRelation ParentData { get; set; } = null!; - [Parameter] public int GetAllTag { get; set; } = SignalRTags.GetAllUserProductMappings; - - [Parameter] public bool ShowNestedRows { get; set; } = false; - - [Parameter] public Guid? ContextId { get; set; } - - private Guid[] ContextIds = new Guid[0]; + [Parameter] public GridDetailExpandButtonDisplayMode DetailExpandButtonDisplayMode { get; set; } = GridDetailExpandButtonDisplayMode.Never; private LoggerClient _logger; - List _availableProducts; + List _availableProducts; private UserProductMappingDriverGrid _driverGrid; - private UserProductMapping tempProductMapping; + private UserProductMapping _tempProductMapping; bool PopupVisible { get; set; } - private DxMaskedInput emailInput; - private DxButton button1; - private ElementReference errorMessage; - private string errorCss = "display: none;"; + private DxMaskedInput _emailInput; + private DxButton _button1; + private ElementReference _errorMessage; + private string _errorCss = "display: none;"; private List FoundUsers { get; set; } = new List(); private string Email { get; set; } = "email@email.com"; string EmailMask { get; set; } = @"(\w|[.-])+@(\w|-)+\.(\w|-){2,4}"; - UserModelDto ChosenUser = null; + UserModelDto _chosenUser = null!; - protected override void OnParametersSet() - { - if (ContextId != null) - { - ContextIds = new Guid[1]; - ContextIds[0] = (Guid)ContextId; - } - base.OnParametersSet(); - } - - protected override async Task OnInitializedAsync() + protected override void OnInitialized() { _logger = new LoggerClient(LogWriters.ToArray()); - - //_logger.Info($"DetailGridData: {_detailGridData.Count}"); + base.OnInitialized(); } void CustomizeEditModel(GridCustomizeEditModelEventArgs e) { if (!e.IsNew) return; - UserProductMapping newUPM = (UserProductMapping)e.EditModel; - newUPM.ProductId = (Guid)ContextId!; + + if (ContextId.IsNullOrEmpty()) + { + _logger.Warning($"ContextId.IsNullOrEmpty()"); + return; + } + + var newUpm = (UserProductMapping)e.EditModel; + newUpm.ProductId = ContextId; + var newProductMapping = new UserProductMapping { Id = Guid.NewGuid(), - ProductId = (Guid)ContextId, + ProductId = (Guid)ContextId, Permissions = 2 }; //e.EditModel = newProductMapping; } - - async Task EditModelSaving(GridEditModelSavingEventArgs e) - { - if (e.IsNew) - - _logger.Info("New orderData added"); - else - _logger.Info("orderData updated"); - - await UpdateDataAsync(); - } - - async Task DataItemDeleting(GridDataItemDeletingEventArgs e) - { - - _logger.Info("orderData deleted"); - - } - - async Task UpdateDataAsync() - { - //refresh grid - _logger.Info("orderData grid refreshed"); - } - async Task FindUser() { - - - var userModelDto = await UserDataService.GetUserByEmailAsync(Email); if (userModelDto != null) { - ChosenUser = userModelDto; - FoundUsers.Add(ChosenUser); - emailInput.Enabled = false; - button1.Visible = false; + _chosenUser = userModelDto; + FoundUsers.Add(_chosenUser); + _emailInput.Enabled = false; + _button1.Visible = false; } else { - emailInput.Value = "email@email.com"; - errorCss = "display: block"; + _emailInput.Value = "email@email.com"; + _errorCss = "display: block"; } } @@ -249,17 +211,18 @@ } - public async Task SubmitForm(object result) + public Task SubmitForm(object result) { - - _logger.Info($"Submitted nested form: {result.GetType().FullName}"); + return Task.CompletedTask; } - public async Task ShowPopup(UserProductMapping emptyProductMapping) + public Task ShowPopup(UserProductMapping emptyProductMapping) { - tempProductMapping = emptyProductMapping; - PopupVisible = true; + _tempProductMapping = emptyProductMapping; + PopupVisible = true; + + return Task.CompletedTask; } private async Task OnUserSelected(Guid userId) @@ -269,13 +232,15 @@ } private async Task OnRowClick(GridRowClickEventArgs e) - { + { await SelectUser((Guid)e.Grid.GetRowValue(e.VisibleIndex, "Id")); } + private async Task SelectUser(Guid id) { PopupVisible = false; - tempProductMapping.UserId = id; + _tempProductMapping.UserId = id; + await OnUserSelected(id); } @@ -283,7 +248,7 @@ { if (e.ElementType == GridElementType.DataRow && (int)e.Grid.GetRowValue(e.VisibleIndex, "Permissions") == 1) { - e.Style="display: none"; + e.Style = "display: none"; } // else if (e.ElementType == GridElementType.HeaderCell) // { @@ -291,7 +256,4 @@ // } } - - - } \ No newline at end of file diff --git a/TIAMSharedUI/Pages/User/SysAdmins/ManageCars.razor b/TIAMSharedUI/Pages/User/SysAdmins/ManageCars.razor index 69320bed..b12da11f 100644 --- a/TIAMSharedUI/Pages/User/SysAdmins/ManageCars.razor +++ b/TIAMSharedUI/Pages/User/SysAdmins/ManageCars.razor @@ -37,7 +37,7 @@ Click="ColumnChooserButton_Click" /> - + diff --git a/TIAMSharedUI/Pages/User/SysAdmins/ManageDrivers.razor b/TIAMSharedUI/Pages/User/SysAdmins/ManageDrivers.razor index 6a08e108..f20fa170 100644 --- a/TIAMSharedUI/Pages/User/SysAdmins/ManageDrivers.razor +++ b/TIAMSharedUI/Pages/User/SysAdmins/ManageDrivers.razor @@ -37,7 +37,7 @@ Click="ColumnChooserButton_Click" /> - + diff --git a/TIAMSharedUI/Pages/User/SysAdmins/ManageUserProductMappings.razor b/TIAMSharedUI/Pages/User/SysAdmins/ManageUserProductMappings.razor index bc673523..48400937 100644 --- a/TIAMSharedUI/Pages/User/SysAdmins/ManageUserProductMappings.razor +++ b/TIAMSharedUI/Pages/User/SysAdmins/ManageUserProductMappings.razor @@ -37,7 +37,7 @@ Click="ColumnChooserButton_Click" /> - + diff --git a/TIAMSharedUI/Pages/User/SysAdmins/ProductDetailGridComponent.razor b/TIAMSharedUI/Pages/User/SysAdmins/ProductDetailGridComponent.razor index 15797a38..561751e6 100644 --- a/TIAMSharedUI/Pages/User/SysAdmins/ProductDetailGridComponent.razor +++ b/TIAMSharedUI/Pages/User/SysAdmins/ProductDetailGridComponent.razor @@ -18,16 +18,13 @@ @using AyCode.Interfaces.Addresses @using AyCode.Core @inject IStringLocalizer Localizer -@inject IServiceProviderDataService serviceProviderDataService -@inject IUserDataService userDataService -@inject ITransferDataService transferDataService @inject IEnumerable LogWriters @inject AdminSignalRClient AdminSignalRClient; - + @@ -62,22 +59,22 @@ - + @{ - var transfer2 = (Product)EditFormContext.EditModel; + var transfer2 = (Product)editFormContext.EditModel; } - @EditFormContext.GetEditor("Name") + @editFormContext.GetEditor("Name") - @EditFormContext.GetEditor("ProductType") + @editFormContext.GetEditor("ProductType") - @EditFormContext.GetEditor("Price") + @editFormContext.GetEditor("Price") - @EditFormContext.GetEditor("Description") + @editFormContext.GetEditor("Description") @@ -89,13 +86,12 @@ @code { [Parameter] public bool KeyboardNavigationEnabled { get; set; } [Parameter] public Guid ContextId { get; set; } - [Parameter] public IProductsRelation ParentData { get; set; } = null!; + [Parameter] public IProductsRelation? ParentData { get; set; } = null!; [Parameter] public EventCallback OnGridEditModelSaving { get; set; } [Parameter] public int GetAllTag { get; set; } = SignalRTags.GetProductsByContextId; [Parameter] public GridDetailExpandButtonDisplayMode DetailExpandButtonDisplayMode { get; set; } = GridDetailExpandButtonDisplayMode.Never; - private ProductDetailGrid _productGrid; - private List productList = new List(); + private ProductDetailGrid _productGrid = null!; private LoggerClient _logger = null!; protected override void OnInitialized() { @@ -121,31 +117,12 @@ // } // else - base.OnParametersSet(); - } - - protected override async Task OnAfterRenderAsync(bool firstRender) - { - // if(firstRender) - // { - - // _productGrid.GetAllMessageTag = GetAllTag; - - // // if (ParentData != null) - // // { - // // _productGrid.DataSource = new List(); - // // _productGrid.DataSource = ParentData.Products; - // // } - - - // } + await base.OnParametersSetAsync(); } private void DataItemChanged(GridDataItemChangedEventArgs args) { _logger.Debug($"Saving: {args.DataItem.Name}, {args.DataItem.ServiceProviderId}"); - - //ProductGrid.SaveChangesAsync(); } public async Task DataItemSaving(GridEditModelSavingEventArgs e) diff --git a/TIAMSharedUI/Pages/User/SysAdmins/UserProductMappingGridComponent.razor b/TIAMSharedUI/Pages/User/SysAdmins/UserProductMappingGridComponent.razor index 72eb9293..5ae522ef 100644 --- a/TIAMSharedUI/Pages/User/SysAdmins/UserProductMappingGridComponent.razor +++ b/TIAMSharedUI/Pages/User/SysAdmins/UserProductMappingGridComponent.razor @@ -29,47 +29,40 @@ CustomizeEditModel="CustomizeEditModel" EditMode="GridEditMode.EditForm" ColumnResizeMode="GridColumnResizeMode.NextColumn" + DetailExpandButtonDisplayMode="DetailExpandButtonDisplayMode" ShowFilterRow="true"> - - + + @{ - if (ShowNestedRows) - { - - - - - - - - - } + + + + + } - + @{ - var transfer2 = (UserProductMapping)UserEditFormContext.EditModel; + var transfer2 = (UserProductMapping)userEditFormContext.EditModel; } - @UserEditFormContext.GetEditor("UserId") + @userEditFormContext.GetEditor("UserId") - + - @UserEditFormContext.GetEditor("Permissions") + @userEditFormContext.GetEditor("Permissions") - - @@ -83,11 +76,9 @@ [Parameter] public int GetAllTag { get; set; } = SignalRTags.GetAllUserProductMappings; - [Parameter] public bool ShowNestedRows { get; set; } = false; + [Parameter] public GridDetailExpandButtonDisplayMode DetailExpandButtonDisplayMode { get; set; } = GridDetailExpandButtonDisplayMode.Never; - [Parameter] public Guid? ContextId { get; set; } - - private Guid[] ContextIds = new Guid[0]; + [Parameter] public Guid[]? ContextIds { get; set; } private LoggerClient _logger; @@ -95,22 +86,12 @@ private ProductDetailGridComponent bleh; - protected override void OnParametersSet() - { - if (ContextId != null) - { - ContextIds = new Guid[1]; - ContextIds[0] = (Guid)ContextId; - } - base.OnParametersSet(); - } - protected override async Task OnInitializedAsync() + protected override void OnInitialized() { _logger = new LoggerClient(LogWriters.ToArray()); - - //_logger.Info($"DetailGridData: {_detailGridData.Count}"); + base.OnInitialized(); } void CustomizeEditModel(GridCustomizeEditModelEventArgs e) @@ -126,30 +107,4 @@ //e.EditModel = newProductMapping; } - - - async Task EditModelSaving(GridEditModelSavingEventArgs e) - { - if (e.IsNew) - - _logger.Info("New orderData added"); - else - _logger.Info("orderData updated"); - - await UpdateDataAsync(); - } - - async Task DataItemDeleting(GridDataItemDeletingEventArgs e) - { - - _logger.Info("orderData deleted"); - - } - - async Task UpdateDataAsync() - { - //refresh grid - _logger.Info("orderData grid refreshed"); - } - } \ No newline at end of file diff --git a/TIAMWebApp/Server/Controllers/ServiceProviderAPIController.cs b/TIAMWebApp/Server/Controllers/ServiceProviderAPIController.cs index 78227ac9..c9c9018a 100644 --- a/TIAMWebApp/Server/Controllers/ServiceProviderAPIController.cs +++ b/TIAMWebApp/Server/Controllers/ServiceProviderAPIController.cs @@ -114,24 +114,24 @@ namespace TIAMWebApp.Server.Controllers [HttpPost] [Route(APIUrls.GetServiceProviderByIdRouteName)] [SignalR(SignalRTags.GetCompany)] - public async Task GetServiceProviderById([FromBody] Guid id) + public Task GetServiceProviderById([FromBody] Guid id) { _logger.Info($@"GetServiceProviderById called with id: {id}"); - return await adminDal.GetCompanyByIdAsync(id); + return adminDal.GetCompanyByIdAsync(id); } - [HttpPost] - [Route(APIUrls.GetServiceProvidersByIdRouteName)] - [SignalR(SignalRTags.GetCompanys)] - public async Task GetServiceProvidersById([FromBody] Guid id) + [NonAction] + [ApiExplorerSettings(IgnoreApi = true)] + [SignalR(SignalRTags.GetCompaniesById)] + public async Task> GetServiceProvidersById(Guid id) { - _logger.Info($@"GetServiceProviderById called with id: {id}"); - List compList = new List(); - var result = await adminDal.GetServiceProviderByIdAsync(id); - compList.Add(result); - return compList.ToJson(); + _logger.Info($@"GetServiceProvidersById called with id: {id}"); + + var company = await GetServiceProviderById(id); + return company == null ? [] : [company]; } + //17. [Authorize] [HttpPost] @@ -486,14 +486,11 @@ namespace TIAMWebApp.Server.Controllers [Route(APIUrls.GetProductByIdRouteName)] [Tags("In-Progress", "Product")] [SignalR(SignalRTags.GetProductById)] - public async Task GetProductById(Guid productId) + public Task GetProductById(Guid productId) { _logger.Info("GetAllProducts called"); - var products = adminDal.GetProductById(productId); - - return products; - + return adminDal.GetProductByIdAsync(productId); } @@ -503,14 +500,9 @@ namespace TIAMWebApp.Server.Controllers public async Task> GetProductsById(Guid productId) { _logger.Info("GetAllProducts called"); - - var product = await GetProductById(productId); - var products = new List(); - if (product != null) { - products.Add(product); - } - return products; + var product = await GetProductById(productId); + return product == null ? [] : [product]; } } } \ No newline at end of file