TourIAm/TIAMWebApp/Shared/Services/AdminSignalRClient.cs

199 lines
8.6 KiB
C#

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<IAcLogWriterClientBase> logWriters) : base($"{Setting.BaseUrl}/DevAdminHub", new LoggerClient(nameof(AdminSignalRClient), logWriters.ToArray()))
{
//var a = ActivatorUtilities.GetServiceOrCreateInstance<TransferDataService>(serviceProvider);
ConstHelper.NameByValue<SignalRTags>(0);
}
#region IUserApiController
public async Task<User?> UpdateUser(User user)
=> await PostDataAsync(SignalRTags.UpdateUser, user);
public async Task<UserModelDtoDetail?> UpdateUserModelDtoDetail(UserModelDtoDetail userModelDtoDetail)
=> await PostDataAsync(SignalRTags.UpdateUserModelDtoDetail, userModelDtoDetail);
public Task<AcErrorCode> UserChangePassword(Guid userId, string oldPassword, string newPassword) => UserChangePassword(new ChangePasswordDto(userId, oldPassword, newPassword));
public Task<AcErrorCode> UserChangePassword(ChangePasswordDto changePasswordDto) => PostDataAsync<ChangePasswordDto, AcErrorCode>(SignalRTags.UserChangePassword, changePasswordDto);
public Task<AcErrorCode> UserForgotPassword(string email, string newPassword) => UserForgotPassword(new ForgotPasswordDto(email, newPassword));
public Task<AcErrorCode> UserForgotPassword(ForgotPasswordDto forgotPasswordDto) => PostDataAsync<ForgotPasswordDto, AcErrorCode>(SignalRTags.UserForgotPassword, forgotPasswordDto);
#endregion IUserApiController
#region ICompanyApiController
public async Task<List<Car>> GetAllCarsByProductId(Guid productId)
{
Logger.Detail($"GetAllCarsByProductId client called; productId: {productId}");
return await GetAllAsync<List<Car>>(SignalRTags.GetAllCarsByProductId, [productId]) ?? [];
}
public Task GetAllCarsAndDriversByProductIdAsync(Guid productId, List<Car> intoCars, List<UserProductMapping> 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<Car> 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<List<Transfer>> GetTransfers()
=> await GetAllAsync<List<Transfer>>(SignalRTags.GetTransfers) ?? [];
public async Task<List<Transfer>> GetTransfersByFilterText(string criteriaOperatorText)
=> await GetAllAsync<List<Transfer>>(SignalRTags.GetTransfersByFilterText, [criteriaOperatorText]) ?? [];
public async Task<List<Transfer>> GetTransfersByUserId(Guid userId)
=> await GetAllAsync<List<Transfer>>(SignalRTags.GetTransfersByUserId, [userId]) ?? [];
public async Task<string> GetTransfersByDriverId(Guid userProductMappingId)
{
throw new NotImplementedException();
}
public async Task<Transfer?> GetTransferById(Guid transferId)
=> await GetByIdAsync<Transfer>(SignalRTags.GetTransfer, transferId);
public async Task<Transfer?> UpdateTransfer(Transfer transfer)
{
throw new NotImplementedException();
}
public async Task<Transfer?> RemoveTransfer(Transfer transfer)
{
throw new NotImplementedException();
}
public async Task<List<UserProductMapping>> GetAllDrivers()
{
throw new NotImplementedException();
}
public async Task<List<UserProductMapping>> GetAllDriversByProductId(Guid productId)
{
throw new NotImplementedException();
}
public async Task<TransferToDriver?> GetTransferDriver(Guid transferDriverId)
{
throw new NotImplementedException();
}
public async Task<List<TransferToDriver>> GetTransferDrivers(Guid transferId)
{
throw new NotImplementedException();
}
public async Task<TransferToDriver?> AddTransferDriver(TransferToDriver transferToDriver)
{
throw new NotImplementedException();
}
public async Task<TransferToDriver?> UpdateTransferDriver(TransferToDriver transferToDriver)
{
throw new NotImplementedException();
}
public async Task<TransferToDriver?> RemoveTransferDriver(TransferToDriver transferToDriver)
{
throw new NotImplementedException();
}
public async Task<List<TransferDestination>> GetTransferDestinations()
=> await GetAllAsync<List<TransferDestination>>(SignalRTags.GetAllTransferDestinations) ?? [];
public Task GetTransferDestinationsAsync(List<TransferDestination> intoDestinationList, Action? callback = null)
=> GetAllIntoAsync(intoDestinationList, SignalRTags.GetAllTransferDestinations, null, callback);
public async Task<List<TransferDestination>> GetPublicTransferDestinations(Guid includeProductId)
=> await GetAllAsync<List<TransferDestination>>(SignalRTags.GetAllTransferDestinationsByProductId, [includeProductId]) ?? [];
public Task GetPublicTransferDestinationsAsync(List<TransferDestination> intoDestinationList, Guid includeProductId, Action? callback = null)
=> GetAllIntoAsync(intoDestinationList, SignalRTags.GetAllTransferDestinationsByProductId, [includeProductId], callback);
public async Task<TransferDestination?> GetTransferDestinationById(Guid transferDestinationId)
{
throw new NotImplementedException();
}
public async Task<TransferDestination?> CreateTransferDestination(TransferDestination transferDestination)
{
throw new NotImplementedException();
}
public async Task<TransferDestination?> UpdateTransferDestination(TransferDestination transferDestination)
{
throw new NotImplementedException();
}
public async Task<TransferDestination?> RemoveTransferDestination(TransferDestination transferDestination)
{
throw new NotImplementedException();
}
public async Task<List<TransferDestinationToProduct>> GetAllTransferDestinationToProducts()
{
throw new NotImplementedException();
}
public async Task<List<TransferDestinationToProduct>> GetTransferDestinationToProductsByProductId(Guid productId)
{
throw new NotImplementedException();
}
public async Task<List<TransferDestinationToProduct>> GetTransferDestinationToProductsByTransferDestinationId(Guid transferDestinationId)
{
throw new NotImplementedException();
}
public async Task<TransferDestinationToProduct?> GetTransferDestinationToProductById(Guid transferDestinationToProductId)
{
throw new NotImplementedException();
}
public async Task<TransferDestinationToProduct?> CreateTransferDestinationToProduct(TransferDestinationToProduct transferDestinationToProduct)
{
throw new NotImplementedException();
}
public async Task<TransferDestinationToProduct?> UpdateTransferDestinationToProduct(TransferDestinationToProduct transferDestinationToProduct)
{
throw new NotImplementedException();
}
public async Task<TransferDestinationToProduct?> RemoveTransferDestinationToProduct(TransferDestinationToProduct transferDestinationToProduct)
{
throw new NotImplementedException();
}
#endregion ITransferApiController
}
}