From 5355bd09cdba2326a8c6924e261fc4f7a64be179 Mon Sep 17 00:00:00 2001 From: Loretta Date: Fri, 30 Aug 2024 16:29:39 +0200 Subject: [PATCH] improvements, fixes, etc... --- TIAM.Database/DataLayers/Admins/AdminDal.cs | 2 +- .../ITransferApiControllerClient.cs | 7 +- .../ITransferApiControllerCommon.cs | 2 +- .../CardComponents/ProductCardComponent.razor | 77 ++++++++--------- .../ProductDetailGridComponent.razor | 9 +- .../User/SysAdmins/ProductGridComponent.razor | 9 +- ...tinationToProductDetailGridComponent.razor | 34 ++++---- ...ferDestinationToProductGridComponent.razor | 8 +- .../Shared/ComboboxItemSelector.razor | 42 ++++----- .../ServiceProviderAPIController.cs | 85 ++++++++++--------- .../Controllers/TransferDataAPIController.cs | 4 +- .../Shared/Services/AdminSignalRClient.cs | 25 ++---- .../Services/ServiceProviderDataService.cs | 7 +- 13 files changed, 147 insertions(+), 164 deletions(-) diff --git a/TIAM.Database/DataLayers/Admins/AdminDal.cs b/TIAM.Database/DataLayers/Admins/AdminDal.cs index b0fce43f..d3cccfdc 100644 --- a/TIAM.Database/DataLayers/Admins/AdminDal.cs +++ b/TIAM.Database/DataLayers/Admins/AdminDal.cs @@ -148,7 +148,7 @@ namespace TIAM.Database.DataLayers.Admins #region TransferDestination - public List GetTransferDestinations() => Session(ctx => ctx.GetTransferDestinations().ToList()); + public Task> GetTransferDestinationsAsync() => SessionAsync(ctx => ctx.GetTransferDestinations().ToList()); public TransferDestination? GetTransferDestinationById(Guid transferDestinationId) => Session(ctx => ctx.GetTransferDestinationById(transferDestinationId)); public Task GetTransferDestinationByIdAsync(Guid transferDestinationId) => SessionAsync(ctx => ctx.GetTransferDestinationById(transferDestinationId)); public string? GetTransferDestinationJsonById(Guid transferDestinationId) => Session(ctx => ctx.GetTransferDestinationById(transferDestinationId)?.ToJson()); diff --git a/TIAM.Services/Interfaces/ITransferApiControllerClient.cs b/TIAM.Services/Interfaces/ITransferApiControllerClient.cs index 59d6b1fd..2104fb72 100644 --- a/TIAM.Services/Interfaces/ITransferApiControllerClient.cs +++ b/TIAM.Services/Interfaces/ITransferApiControllerClient.cs @@ -1,5 +1,8 @@ -namespace TIAM.Services.Interfaces; +using TIAM.Entities.Transfers; -public interface ITransferApiControllerClient : IUserApiControllerCommon +namespace TIAM.Services.Interfaces; + +public interface ITransferApiControllerClient : ITransferApiControllerCommon { + Task GetTransferDestinationsInto(List intoDestinationList, Action? callback = null); } \ No newline at end of file diff --git a/TIAM.Services/Interfaces/ITransferApiControllerCommon.cs b/TIAM.Services/Interfaces/ITransferApiControllerCommon.cs index a2925269..02b8158e 100644 --- a/TIAM.Services/Interfaces/ITransferApiControllerCommon.cs +++ b/TIAM.Services/Interfaces/ITransferApiControllerCommon.cs @@ -26,7 +26,7 @@ public interface ITransferApiControllerCommon #endregion Drivers #region TransferDestination - public List GetTransferDestinations(); + public Task> GetTransferDestinations(); public Task GetTransferDestinationById(Guid transferDestinationId); public Task CreateTransferDestination(TransferDestination transferDestination); public Task UpdateTransferDestination(TransferDestination transferDestination); diff --git a/TIAMSharedUI/Pages/User/CardComponents/ProductCardComponent.razor b/TIAMSharedUI/Pages/User/CardComponents/ProductCardComponent.razor index e505c230..a9c95b7b 100644 --- a/TIAMSharedUI/Pages/User/CardComponents/ProductCardComponent.razor +++ b/TIAMSharedUI/Pages/User/CardComponents/ProductCardComponent.razor @@ -1,4 +1,5 @@ -@using BlazorAnimation +@using AyCode.Core.Helpers +@using BlazorAnimation @using TIAM.Core.Enums @using TIAM.Entities.Addresses @using TIAM.Entities.Products @@ -42,7 +43,7 @@

Information

- @RenderDetailsItem("fa-solid fa-user", "Contact Name", productProfile.FullName) + @RenderDetailsItem("fa-solid fa-user", "Contact Name", _productProfile.FullName) @RenderDetailsItem("fa-solid fa-circle-info", "Description", Context.Description)
@@ -79,16 +80,16 @@
@{ - if (!isAddressTransferDestination) + if (!_isAddressTransferDestination) { - + } }
-

@msg

+

@_msg

@@ -120,11 +121,11 @@ AccordionExpandMode ExpandMode { get; set; } = AccordionExpandMode.SingleOrNone; AccordionExpandCollapseAction ExpandCollapseAction { get; set; } = AccordionExpandCollapseAction.HeaderClick; - private Profile productProfile = new Profile(); - private List destinations = new List(); - string msg; - private bool isSaveActive = false; - private bool isAddressTransferDestination = false; + private Profile _productProfile = new Profile(); + private readonly List _destinations = []; + string _msg; + private bool _isSaveActive = false; + private bool _isAddressTransferDestination = false; private async Task CopyUrl(string url) { @@ -139,19 +140,20 @@ protected override async Task OnInitializedAsync() { var productOwner = await AdminSignalRClient.GetByIdAsync>(SignalRTags.GetCompaniesById, Context.ServiceProviderId); - var ProductProfiles = await AdminSignalRClient.GetByIdAsync>(SignalRTags.GetProfileById, Context.ProfileId); - await AdminSignalRClient.GetAllIntoAsync(destinations, SignalRTags.GetAllTransferDestinations); + var productProfiles = await AdminSignalRClient.GetByIdAsync>(SignalRTags.GetProfileById, Context.ProfileId); + if (productOwner != null) { - ImageSource = await ServiceProviderDataService.GetQRCodeByProductIdAndOwnerAffiliateIdAsync(new Guid[] { productOwner[0].AffiliateId, Context.Id }); - } - if (ProductProfiles != null) - { - productProfile = ProductProfiles[0]; - var AddressId = productProfile.AddressId; - isAddressTransferDestination = CheckDestinations(AddressId); + ImageSource = await ServiceProviderDataService.GetQRCodeByProductIdAndOwnerAffiliateIdAsync([productOwner[0].AffiliateId, Context.Id]); } + if (productProfiles != null) + { + _productProfile = productProfiles[0]; + _isAddressTransferDestination = CheckDestinations(_productProfile.AddressId); + } + + AdminSignalRClient.GetTransferDestinationsInto(_destinations).Forget(); await base.OnInitializedAsync(); } @@ -163,40 +165,27 @@ RenderFragment RenderDetailsItem(string iconCssClass, string caption, string value) { return @
-
- -
-
- -
@value
-
-
; +
+ +
+
+ +
@value
+
+ ; } private bool CheckDestinations(Guid addressId) { - if (destinations != null) - { - if (destinations.Any(d => d.AddressId == addressId)) - { - return true; - } - else - { - return false; - } - } - else - { - return false; - } + return _destinations.Any(d => d.AddressId == addressId); } private async Task SaveAsDestination(Address address, Product product) { - TransferDestination transferDestination = new TransferDestination(); + var transferDestination = new TransferDestination(); transferDestination.Id = Guid.NewGuid(); transferDestination.Name = product.Name; + if (!string.IsNullOrEmpty(product.Profile.Description)) { transferDestination.Description = product.Profile.Description; @@ -205,8 +194,10 @@ { transferDestination.Description = "No description available"; } + transferDestination.AddressId = address.Id; transferDestination.AddressString = address.AddressText; + var result = await AdminSignalRClient.PostDataAsync(SignalRTags.CreateTransferDestination, transferDestination); await InvokeAsync(StateHasChanged); } diff --git a/TIAMSharedUI/Pages/User/SysAdmins/ProductDetailGridComponent.razor b/TIAMSharedUI/Pages/User/SysAdmins/ProductDetailGridComponent.razor index 7a436f9e..7927f52e 100644 --- a/TIAMSharedUI/Pages/User/SysAdmins/ProductDetailGridComponent.razor +++ b/TIAMSharedUI/Pages/User/SysAdmins/ProductDetailGridComponent.razor @@ -143,7 +143,7 @@ [Parameter] public GridDetailExpandButtonDisplayMode DetailExpandButtonDisplayMode { get; set; } = GridDetailExpandButtonDisplayMode.Never; [Parameter] public bool ShowManageButtons { get; set; } = false; - private List destinations = []; + private List _destinations = []; private ProductDetailGrid _productGrid = null!; private LoggerClient _logger = null!; @@ -157,7 +157,8 @@ protected override void OnInitialized() { _logger = new LoggerClient(LogWriters.ToArray()); - AdminSignalRClient.GetAllIntoAsync(destinations, SignalRTags.GetAllTransferDestinations).Forget(); + + AdminSignalRClient.GetTransferDestinationsInto(_destinations).Forget(); //DataSource = new List
(); } @@ -166,9 +167,9 @@ { - if(destinations!=null) + if(_destinations!=null) { - if (destinations.Any(d => d.AddressId == addressId)) + if (_destinations.Any(d => d.AddressId == addressId)) { return true; } diff --git a/TIAMSharedUI/Pages/User/SysAdmins/ProductGridComponent.razor b/TIAMSharedUI/Pages/User/SysAdmins/ProductGridComponent.razor index c17c9960..0165a30e 100644 --- a/TIAMSharedUI/Pages/User/SysAdmins/ProductGridComponent.razor +++ b/TIAMSharedUI/Pages/User/SysAdmins/ProductGridComponent.razor @@ -144,7 +144,7 @@ [Parameter] public EventCallback OnGridEditModelSaving { get; set; } [Parameter] public GridDetailExpandButtonDisplayMode DetailExpandButtonDisplayMode { get; set; } = GridDetailExpandButtonDisplayMode.Never; - private List destinations = []; + private List _destinations = []; private ProductGrid _productGrid = null!; private LoggerClient _logger = null!; @@ -159,16 +159,17 @@ protected override void OnInitialized() { _logger = new LoggerClient(LogWriters.ToArray()); - AdminSignalRClient.GetAllIntoAsync(destinations, SignalRTags.GetAllTransferDestinations).Forget(); + + AdminSignalRClient.GetTransferDestinationsInto(_destinations).Forget(); } private bool CheckDestinations(Guid addressId) { - if (destinations != null) + if (_destinations != null) { - if (destinations.Any(d => d.AddressId == addressId)) + if (_destinations.Any(d => d.AddressId == addressId)) { return true; } diff --git a/TIAMSharedUI/Pages/User/SysAdmins/TransferDestinationToProductDetailGridComponent.razor b/TIAMSharedUI/Pages/User/SysAdmins/TransferDestinationToProductDetailGridComponent.razor index 075e9710..93135d5c 100644 --- a/TIAMSharedUI/Pages/User/SysAdmins/TransferDestinationToProductDetailGridComponent.razor +++ b/TIAMSharedUI/Pages/User/SysAdmins/TransferDestinationToProductDetailGridComponent.razor @@ -36,10 +36,10 @@ @{ - var TransferDestinationToProductEditModel = (TransferDestinationToProduct)context.EditModel; + var transferDestinationToProductEditModel = (TransferDestinationToProduct)context.EditModel; } - @@ -47,10 +47,10 @@ @{ - var TransferDestinationToProductEditModel = (TransferDestinationToProduct)context.EditModel; + var transferDestinationToProductEditModel = (TransferDestinationToProduct)context.EditModel; } - @@ -111,11 +111,11 @@ [Parameter] public bool IsProductIdReadonly { get; set; } = false; [Parameter] public bool IsDestinationIdReadonly { get; set; } = false; - private bool ProductIdReadOnly = false; - private bool DestinationIdReadOnly = false; + private bool _productIdReadOnly = false; + private bool _destinationIdReadOnly = false; //private bool? _isNewState = null; - private List _transferDestinations = []; + private List _destinations = []; private List _products = []; private LoggerClient _logger = null!; @@ -123,8 +123,10 @@ protected override void OnInitialized() { _logger = new LoggerClient(LogWriters.ToArray()); - AdminSignalRClient.GetAllIntoAsync(_transferDestinations, SignalRTags.GetAllTransferDestinations).Forget(); + + AdminSignalRClient.GetTransferDestinationsInto(_destinations).Forget(); AdminSignalRClient.GetAllIntoAsync(_products, SignalRTags.GetAllProducts).Forget(); + base.OnInitialized(); } @@ -132,9 +134,9 @@ { if (!e.IsNew) { - DestinationIdReadOnly = true; + _destinationIdReadOnly = true; - ProductIdReadOnly = true; + _productIdReadOnly = true; } else @@ -143,12 +145,12 @@ { ((TransferDestinationToProduct)(e.EditModel)).TransferDestinationId = (Guid)ContextIds[0]; } - DestinationIdReadOnly = IsDestinationIdReadonly; + _destinationIdReadOnly = IsDestinationIdReadonly; if (IsProductIdReadonly) { ((TransferDestinationToProduct)(e.EditModel)).ProductId = (Guid)ContextIds[0]; } - ProductIdReadOnly = IsProductIdReadonly; + _productIdReadOnly = IsProductIdReadonly; } if (!e.IsNew) return; @@ -157,14 +159,14 @@ private void OnGridEditModelSaving(GridEditModelSavingEventArgs e) { - DestinationIdReadOnly = false; - ProductIdReadOnly = false; + _destinationIdReadOnly = false; + _productIdReadOnly = false; } private void EditCanceling(GridEditCancelingEventArgs e) { - DestinationIdReadOnly = false; - ProductIdReadOnly = false; + _destinationIdReadOnly = false; + _productIdReadOnly = false; } diff --git a/TIAMSharedUI/Pages/User/SysAdmins/TransferDestinationToProductGridComponent.razor b/TIAMSharedUI/Pages/User/SysAdmins/TransferDestinationToProductGridComponent.razor index 9ee683bf..f7d0f55d 100644 --- a/TIAMSharedUI/Pages/User/SysAdmins/TransferDestinationToProductGridComponent.razor +++ b/TIAMSharedUI/Pages/User/SysAdmins/TransferDestinationToProductGridComponent.razor @@ -47,7 +47,7 @@ var TransferDestinationToProductEditModel = (TransferDestinationToProduct)context.EditModel; } - @@ -101,15 +101,17 @@ private LoggerClient _logger = null!; private bool? _isNewState = null; - private List _transferDestinations = []; + private List _destinations = []; private List _products = []; protected override async Task OnInitializedAsync() { _logger = new LoggerClient(LogWriters.ToArray()); - AdminSignalRClient.GetAllIntoAsync(_transferDestinations, SignalRTags.GetAllTransferDestinations).Forget(); + + AdminSignalRClient.GetTransferDestinationsInto(_destinations).Forget(); AdminSignalRClient.GetAllIntoAsync(_products, SignalRTags.GetAllProducts).Forget(); + await base.OnInitializedAsync(); } diff --git a/TIAMSharedUI/Shared/ComboboxItemSelector.razor b/TIAMSharedUI/Shared/ComboboxItemSelector.razor index fce38927..90e9d01c 100644 --- a/TIAMSharedUI/Shared/ComboboxItemSelector.razor +++ b/TIAMSharedUI/Shared/ComboboxItemSelector.razor @@ -25,7 +25,7 @@ - -

Selected address: @Address

+

Selected address: @_address

@*

@@ -81,18 +81,16 @@ [Parameter] public Guid? ProductId { get; set; } - public List Destinations = []; - public DxTextBox TextField; TransferDestination Result; ILogger _logger; - List Data { get; set; } = []; + readonly List _destinations = []; - private string Address { get; set; } - private string ValidationMessage { get; set; } + private string _address = string.Empty; + private string _validationMessage = string.Empty; private TransferDestination? _selectedDestination; public TransferDestination? SelectedDestination @@ -129,25 +127,19 @@ } } - _adminSignalRClient.GetAllAsync>(SignalRTags.GetAllTransferDestinations, response => + _adminSignalRClient.GetTransferDestinationsInto(_destinations, () => { - Data.Clear(); - SelectedDestination = null; - - if (response.Status != SignalResponseStatus.Success || response.ResponseData == null) - { - _logger.Error($"OnInitializedAsync->GetAllTransferDestinations; response.Status: {response.Status}"); - return Task.CompletedTask; - } - - Data.AddRange(response.ResponseData); - - _logger.Debug($"TransferDestinations Data length: {Data.Count}"); - SelectedDestination = productAddressId.IsNullOrEmpty() ? Data.FirstOrDefault() : Data.FirstOrDefault(x => x.AddressId == productAddressId); - - return Task.CompletedTask; + SelectedDestination = productAddressId.IsNullOrEmpty() ? _destinations.FirstOrDefault() : _destinations.FirstOrDefault(x => x.AddressId == productAddressId); }).Forget(); + // _adminSignalRClient.GetAllIntoAsync(_destinations, SignalRTags.GetAllTransferDestinations, null, resultData => + // { + // if (resultData == null) SelectedDestination = null; + // else SelectedDestination = productAddressId.IsNullOrEmpty() ? _destinations.FirstOrDefault() : _destinations.FirstOrDefault(x => x.AddressId == productAddressId); + + // return Task.CompletedTask; + // }).Forget(); + //await _adminSignalRClient.GetAllIntoAsync(Data, SignalRTags.GetAllTransferDestinations); } @@ -170,13 +162,13 @@ public void OnSelectedAddressChanged(string address) { - Address = address; + _address = address; OnSliderChanged.InvokeAsync(address); } public void SetNewDestination(string address) { - Address = address; + _address = address; OnSliderChanged.InvokeAsync(address); } diff --git a/TIAMWebApp/Server/Controllers/ServiceProviderAPIController.cs b/TIAMWebApp/Server/Controllers/ServiceProviderAPIController.cs index f085fce6..e137d9a4 100644 --- a/TIAMWebApp/Server/Controllers/ServiceProviderAPIController.cs +++ b/TIAMWebApp/Server/Controllers/ServiceProviderAPIController.cs @@ -497,64 +497,69 @@ namespace TIAMWebApp.Server.Controllers [Tags("In-Progress", "Product")] public async Task GetQRCodeByProductId([FromBody] Guid productId) { - _logger.Info(@"GetQRCode called"); + _logger.Info($"GetQRCode called; productId: {productId}"); - if (productId == Guid.Empty) - { - return BadRequest("Product is required"); - } - else - { - //var result = _serviceProviderDal.GetQRCodeAsync(productId); + return BadRequest("OBSOLATE"); + if (productId.IsNullOrEmpty()) return BadRequest("Product is required"); - var qrGenerator = new QRCodeGenerator(); - var qrCodeData = qrGenerator.CreateQrCode($"https://touriam.com/{productId}", QRCodeGenerator.ECCLevel.Q); - var qrCode = new QRCode(qrCodeData); - //Bitmap qrCodeImage = qrCode.GetGraphic(20); - //var rootpath = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), "assets"); - var rootpath = System.IO.Path.Combine(env.WebRootPath, "assets"); - var qrCodeImage = qrCode.GetGraphic(20, Color.DarkMagenta, Color.White, (Bitmap)Bitmap.FromFile(rootpath + "/myimage.png")); - _logger.Info($@"qrCodeLogo: {rootpath}/myimage.png"); - var ms = new MemoryStream(); + //var result = _serviceProviderDal.GetQRCodeAsync(productId); + + var qrGenerator = new QRCodeGenerator(); + var qrCodeData = qrGenerator.CreateQrCode($"https://touriam.com/{productId}", QRCodeGenerator.ECCLevel.Q); + var qrCode = new QRCode(qrCodeData); + + //Bitmap qrCodeImage = qrCode.GetGraphic(20); + //var rootpath = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), "assets"); + var rootpath = Path.Combine(env.WebRootPath, "assets"); + var qrCodeImage = qrCode.GetGraphic(20, Color.DarkMagenta, Color.White, (Bitmap)Bitmap.FromFile(rootpath + "/myimage.png")); + + _logger.Debug($@"qrCodeLogo: {rootpath}/myimage.png"); + + byte[] byteImage; + using (var ms = new MemoryStream()) + { qrCodeImage.Save(ms, ImageFormat.Jpeg); - var byteImage = ms.ToArray(); - - var sigBase64 = Convert.ToBase64String(byteImage); // Get Base64 - - return Ok(sigBase64); + byteImage = ms.ToArray(); } + + var sigBase64 = Convert.ToBase64String(byteImage); // Get Base64 + + return Ok(sigBase64); } [AllowAnonymous] [HttpPost] [Route(APIUrls.GetQrCodeByProductIdAndOwnerAffiliateIdRouteName)] - public async Task GetQrCodeByProductIdAndOwnerAffiliateId([FromBody] Guid[] Ids) + public async Task GetQrCodeByProductIdAndOwnerAffiliateId([FromBody] Guid[] ids) { _logger.Info(@"GetQRCode called"); - if (Ids[0].IsNullOrEmpty() || Ids[1].IsNullOrEmpty()) + if (ids[0].IsNullOrEmpty() || ids[1].IsNullOrEmpty()) { return BadRequest("Product is required"); } - else + + var qrGenerator = new QRCodeGenerator(); + var qrCodeData = qrGenerator.CreateQrCode($"{Setting.BaseUrl}/public/transfer/{ids[0]}/{ids[1]}", QRCodeGenerator.ECCLevel.Q); + var qrCode = new QRCode(qrCodeData); + + //Bitmap qrCodeImage = qrCode.GetGraphic(20); + //var rootpath = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), "assets"); + var rootpath = Path.Combine(env.WebRootPath, "assets"); + var qrCodeImage = qrCode.GetGraphic(20, Color.DarkMagenta, Color.White, (Bitmap)Bitmap.FromFile(rootpath + "/myimage.png")); + + _logger.Info($@"qrCodeLogo: {rootpath}/myimage.png"); + + byte[] byteImage; + using (var ms = new MemoryStream()) { - - var qrGenerator = new QRCodeGenerator(); - var qrCodeData = qrGenerator.CreateQrCode($"{Setting.BaseUrl}/public/transfer/{Ids[0]}/{Ids[1]}", QRCodeGenerator.ECCLevel.Q); - var qrCode = new QRCode(qrCodeData); - //Bitmap qrCodeImage = qrCode.GetGraphic(20); - //var rootpath = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), "assets"); - var rootpath = System.IO.Path.Combine(env.WebRootPath, "assets"); - var qrCodeImage = qrCode.GetGraphic(20, Color.DarkMagenta, Color.White, (Bitmap)Bitmap.FromFile(rootpath + "/myimage.png")); - _logger.Info($@"qrCodeLogo: {rootpath}/myimage.png"); - var ms = new MemoryStream(); qrCodeImage.Save(ms, ImageFormat.Jpeg); - var byteImage = ms.ToArray(); - - var sigBase64 = Convert.ToBase64String(byteImage); // Get Base64 - - return Ok(sigBase64); + byteImage = ms.ToArray(); } + + var sigBase64 = Convert.ToBase64String(byteImage); // Get Base64 + + return Ok(sigBase64); } } } \ No newline at end of file diff --git a/TIAMWebApp/Server/Controllers/TransferDataAPIController.cs b/TIAMWebApp/Server/Controllers/TransferDataAPIController.cs index 38a200e0..a04aa8f8 100644 --- a/TIAMWebApp/Server/Controllers/TransferDataAPIController.cs +++ b/TIAMWebApp/Server/Controllers/TransferDataAPIController.cs @@ -77,9 +77,9 @@ namespace TIAMWebApp.Server.Controllers [HttpGet] [Route(APIUrls.GetTransferDestinationsRouteName)] [SignalR(SignalRTags.GetAllTransferDestinations)] - public List GetTransferDestinations() + public async Task> GetTransferDestinations() { - return _adminDal.GetTransferDestinations(); + return await _adminDal.GetTransferDestinationsAsync(); } //[Authorize] diff --git a/TIAMWebApp/Shared/Services/AdminSignalRClient.cs b/TIAMWebApp/Shared/Services/AdminSignalRClient.cs index e87959cd..8e423118 100644 --- a/TIAMWebApp/Shared/Services/AdminSignalRClient.cs +++ b/TIAMWebApp/Shared/Services/AdminSignalRClient.cs @@ -2,7 +2,6 @@ using AyCode.Core.Consts; using AyCode.Core.Helpers; using AyCode.Services.Loggers; -using AyCode.Services.SignalRs; using TIAM.Entities.Drivers; using TIAM.Entities.Transfers; using TIAM.Entities.Users; @@ -58,19 +57,7 @@ namespace TIAMWebApp.Shared.Application.Services { Logger.Detail($"GetAllCarsByProductIdAsync client called; productId: {productId}"); - //TODO: AdminSignalRClient.GetAllIntoAsync(_cars, SignalRTags.GetAllCarsByProductId, [productId]) - J. - return GetAllAsync>(SignalRTags.GetAllCarsByProductId, response => - { - intoCars.Clear(); - if (response is { Status: SignalResponseStatus.Success, ResponseData: not null }) - { - intoCars.AddRange(response.ResponseData); - } - - callback?.Invoke(); - - return Task.CompletedTask; - }, [productId]); + return GetAllIntoAsync(intoCars, SignalRTags.GetAllCarsByProductId, [productId], callback); } #endregion ICompanyApiController @@ -137,10 +124,12 @@ namespace TIAMWebApp.Shared.Application.Services throw new NotImplementedException(); } - public List GetTransferDestinations() - { - throw new NotImplementedException(); - } + public async Task> GetTransferDestinations() + => await GetAllAsync>(SignalRTags.GetAllTransferDestinations) ?? []; + + public Task GetTransferDestinationsInto(List intoDestinationList, Action? callback = null) + => GetAllIntoAsync(intoDestinationList, SignalRTags.GetAllTransferDestinations, null, callback); + public async Task GetTransferDestinationById(Guid transferDestinationId) { diff --git a/TIAMWebApp/Shared/Services/ServiceProviderDataService.cs b/TIAMWebApp/Shared/Services/ServiceProviderDataService.cs index 7d0a70b8..b050a6f4 100644 --- a/TIAMWebApp/Shared/Services/ServiceProviderDataService.cs +++ b/TIAMWebApp/Shared/Services/ServiceProviderDataService.cs @@ -199,8 +199,6 @@ namespace TIAMWebApp.Shared.Application.Services public async Task GetQRCodeByProductIdAsync(Guid productId) { - - var url = APIUrls.GetQrCodeByProductId; var response = await http.PostAsJsonAsync(url, productId); if (response.IsSuccessStatusCode) @@ -215,11 +213,10 @@ namespace TIAMWebApp.Shared.Application.Services } } - public async Task GetQRCodeByProductIdAndOwnerAffiliateIdAsync(Guid[] Ids) + public async Task GetQRCodeByProductIdAndOwnerAffiliateIdAsync(Guid[] ids) { - var url = APIUrls.GetQrCodeByProductIdAndOwnerAffiliateId; - var response = await http.PostAsJsonAsync(url, Ids); + var response = await http.PostAsJsonAsync(url, ids); if (response.IsSuccessStatusCode) { var result = await response.Content.ReadAsStringAsync();