using AyCode.Blazor.Components.Services; using AyCode.Core.Consts; using AyCode.Core.Helpers; using AyCode.Services.Loggers; using Microsoft.Extensions.DependencyInjection; using TIAM.Entities.Drivers; using TIAM.Entities.Transfers; using TIAM.Entities.Users; using TIAM.Models.Dtos.Users; using TIAM.Services; using TIAM.Services.Interfaces; using TIAMWebApp.Shared.Application.Models.ClientSide; using TIAMWebApp.Shared.Application.Utility; namespace TIAMWebApp.Shared.Application.Services { public class AdminSignalRClient : AcSignalRClientBase, IUserApiControllerClient, ITransferApiControllerClient { public AdminSignalRClient(/*IServiceProvider serviceProvider, */IEnumerable logWriters) : base($"{Setting.BaseUrl}/DevAdminHub", new LoggerClient(nameof(AdminSignalRClient), logWriters.ToArray())) { //var a = ActivatorUtilities.GetServiceOrCreateInstance(serviceProvider); ConstHelper.NameByValue(0); } #region IUserApiController public async Task UpdateUser(User user) => await PostDataAsync(SignalRTags.UpdateUser, user); public async Task UpdateUserModelDtoDetail(UserModelDtoDetail userModelDtoDetail) => await PostDataAsync(SignalRTags.UpdateUserModelDtoDetail, userModelDtoDetail); public Task UserChangePassword(Guid userId, string oldPassword, string newPassword) => UserChangePassword(new ChangePasswordDto(userId, oldPassword, newPassword)); public Task UserChangePassword(ChangePasswordDto changePasswordDto) => PostDataAsync(SignalRTags.UserChangePassword, changePasswordDto); public Task UserForgotPassword(string email, string newPassword) => UserForgotPassword(new ForgotPasswordDto(email, newPassword)); public Task UserForgotPassword(ForgotPasswordDto forgotPasswordDto) => PostDataAsync(SignalRTags.UserForgotPassword, forgotPasswordDto); #endregion IUserApiController #region ICompanyApiController public async Task> GetAllCarsByProductId(Guid productId) { Logger.Detail($"GetAllCarsByProductId client called; productId: {productId}"); return await GetAllAsync>(SignalRTags.GetAllCarsByProductId, [productId]) ?? []; } public Task GetAllCarsAndDriversByProductIdAsync(Guid productId, List intoCars, List intoDrivers, Action? callback = null) { return GetAllCarsByProductIdAsync(productId, intoCars, () => { intoDrivers.Clear(); intoDrivers.AddRange(intoCars.DistinctBy(x => x.UserProductMappingId).Select(x => x.UserProductMapping)); callback?.Invoke(); }); } public Task GetAllCarsByProductIdAsync(Guid productId, List intoCars, Action? callback = null) { Logger.Detail($"GetAllCarsByProductIdAsync client called; productId: {productId}"); return GetAllIntoAsync(intoCars, SignalRTags.GetAllCarsByProductId, [productId], callback); } #endregion ICompanyApiController #region ITransferApiController public async Task> GetTransfers() => await GetAllAsync>(SignalRTags.GetTransfers) ?? []; public async Task> GetTransfersByFilterText(string criteriaOperatorText) => await GetAllAsync>(SignalRTags.GetTransfersByFilterText, [criteriaOperatorText]) ?? []; public async Task> GetTransfersByUserId(Guid userId) => await GetAllAsync>(SignalRTags.GetTransfersByUserId, [userId]) ?? []; public async Task GetTransfersByDriverId(Guid userProductMappingId) { throw new NotImplementedException(); } public async Task GetTransferById(Guid transferId) => await GetByIdAsync(SignalRTags.GetTransfer, transferId); public async Task UpdateTransfer(Transfer transfer) { throw new NotImplementedException(); } public async Task RemoveTransfer(Transfer transfer) { throw new NotImplementedException(); } public async Task> GetAllDrivers() { throw new NotImplementedException(); } public async Task> GetAllDriversByProductId(Guid productId) { throw new NotImplementedException(); } public async Task GetTransferDriver(Guid transferDriverId) { throw new NotImplementedException(); } public async Task> GetTransferDrivers(Guid transferId) { throw new NotImplementedException(); } public async Task AddTransferDriver(TransferToDriver transferToDriver) { throw new NotImplementedException(); } public async Task UpdateTransferDriver(TransferToDriver transferToDriver) { throw new NotImplementedException(); } public async Task RemoveTransferDriver(TransferToDriver transferToDriver) { throw new NotImplementedException(); } public async Task> GetTransferDestinations() => await GetAllAsync>(SignalRTags.GetAllTransferDestinations) ?? []; public Task GetTransferDestinationsAsync(List intoDestinationList, Action? callback = null) => GetAllIntoAsync(intoDestinationList, SignalRTags.GetAllTransferDestinations, null, callback); public async Task> GetPublicTransferDestinations(Guid includeProductId) => await GetAllAsync>(SignalRTags.GetAllTransferDestinationsByProductId, [includeProductId]) ?? []; public Task GetPublicTransferDestinationsAsync(List intoDestinationList, Guid includeProductId, Action? callback = null) => GetAllIntoAsync(intoDestinationList, SignalRTags.GetAllTransferDestinationsByProductId, [includeProductId], callback); public async Task GetTransferDestinationById(Guid transferDestinationId) { throw new NotImplementedException(); } public async Task CreateTransferDestination(TransferDestination transferDestination) { throw new NotImplementedException(); } public async Task UpdateTransferDestination(TransferDestination transferDestination) { throw new NotImplementedException(); } public async Task RemoveTransferDestination(TransferDestination transferDestination) { throw new NotImplementedException(); } public async Task> GetAllTransferDestinationToProducts() { throw new NotImplementedException(); } public async Task> GetTransferDestinationToProductsByProductId(Guid productId) { throw new NotImplementedException(); } public async Task> GetTransferDestinationToProductsByTransferDestinationId(Guid transferDestinationId) { throw new NotImplementedException(); } public async Task GetTransferDestinationToProductById(Guid transferDestinationToProductId) { throw new NotImplementedException(); } public async Task CreateTransferDestinationToProduct(TransferDestinationToProduct transferDestinationToProduct) { throw new NotImplementedException(); } public async Task UpdateTransferDestinationToProduct(TransferDestinationToProduct transferDestinationToProduct) { throw new NotImplementedException(); } public async Task RemoveTransferDestinationToProduct(TransferDestinationToProduct transferDestinationToProduct) { throw new NotImplementedException(); } #endregion ITransferApiController } }