202 lines
8.1 KiB
C#
202 lines
8.1 KiB
C#
using AyCode.Blazor.Components.Services;
|
|
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;
|
|
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(IEnumerable<IAcLogWriterClientBase> logWriters) : base($"{Setting.BaseUrl}/DevAdminHub", new LoggerClient(nameof(AdminSignalRClient), logWriters.ToArray()))
|
|
{
|
|
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}");
|
|
|
|
//TODO: AdminSignalRClient.GetAllIntoAsync<Car>(_cars, SignalRTags.GetAllCarsByProductId, [productId]) - J.
|
|
return GetAllAsync<List<Car>>(SignalRTags.GetAllCarsByProductId, response =>
|
|
{
|
|
if (response is { Status: SignalResponseStatus.Success, ResponseData: not null })
|
|
{
|
|
intoCars.Clear();
|
|
intoCars.AddRange(response.ResponseData);
|
|
}
|
|
|
|
callback?.Invoke();
|
|
|
|
return Task.CompletedTask;
|
|
}, [productId]);
|
|
}
|
|
#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 List<TransferDestination> GetTransferDestinations()
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
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
|
|
}
|
|
}
|