improvements, fixes, etc...

This commit is contained in:
Loretta 2024-07-01 08:58:15 +02:00
parent add3685a59
commit ef016d24ac
11 changed files with 142 additions and 72 deletions

View File

@ -40,6 +40,7 @@ namespace TIAM.Database.DataLayers.Admins
} }
#region Car #region Car
public Task<List<Car>> GetAllCarsAsync() => SessionAsync(ctx => ctx.Cars.OrderBy(x => x.Manufacture).ThenBy(x => x.CarModel).ToList()); public Task<List<Car>> GetAllCarsAsync() => SessionAsync(ctx => ctx.Cars.OrderBy(x => x.Manufacture).ThenBy(x => x.CarModel).ToList());
public Task<List<Car>> GetAllCarsbyProductIdAsync(Guid productId) => SessionAsync(ctx => ctx.Cars.Where(x => x.UserProductMapping.ProductId == productId).OrderBy(x => x.Manufacture).ThenBy(x => x.CarModel).ToList()); public Task<List<Car>> GetAllCarsbyProductIdAsync(Guid productId) => SessionAsync(ctx => ctx.Cars.Where(x => x.UserProductMapping.ProductId == productId).OrderBy(x => x.Manufacture).ThenBy(x => x.CarModel).ToList());
public Car? GetCarById(Guid carId) => Session(ctx => ctx.Cars.FirstOrDefault(x => x.Id == carId)); public Car? GetCarById(Guid carId) => Session(ctx => ctx.Cars.FirstOrDefault(x => x.Id == carId));
@ -102,7 +103,8 @@ namespace TIAM.Database.DataLayers.Admins
//} //}
public Task<bool> UpdateTransferAsync(Transfer transfer, TransferToDriver transferToDriver) => UpdateTransferAsync(transfer, [transferToDriver]); public Task<bool> UpdateTransferAsync(Transfer transfer, TransferToDriver transferToDriver) => UpdateTransferAsync(transfer, [transferToDriver]);
public Task<bool> UpdateTransferAsync(Transfer transfer, List<TransferToDriver> transferToDrivers)
public Task<bool> UpdateTransferAsync(Transfer transfer, List<TransferToDriver> transferToDrivers)
=> TransactionAsync(ctx => => TransactionAsync(ctx =>
{ {
ctx.AddRange(transferToDrivers); ctx.AddRange(transferToDrivers);
@ -113,27 +115,31 @@ namespace TIAM.Database.DataLayers.Admins
public Task<bool> RemoveTransferAsync(Transfer transfer) => RemoveTransferAsync(transfer.Id); public Task<bool> RemoveTransferAsync(Transfer transfer) => RemoveTransferAsync(transfer.Id);
public Task<bool> RemoveTransferAsync(Guid transferId) => TransactionAsync(ctx => ctx.RemoveTransfer(transferId)); public Task<bool> RemoveTransferAsync(Guid transferId) => TransactionAsync(ctx => ctx.RemoveTransfer(transferId));
#endregion Transfer #endregion Transfer
#region TransferDestination #region TransferDestination
public List<TransferDestination> GetTransferDestinations() => Session(ctx=>ctx.GetTransferDestinations().ToList());
public TransferDestination? GetTransferDestinationById(Guid transferDestinationId) => Session(ctx=>ctx.GetTransferDestinationById(transferDestinationId)); public List<TransferDestination> GetTransferDestinations() => Session(ctx => ctx.GetTransferDestinations().ToList());
public Task<TransferDestination?> GetTransferDestinationByIdAsync(Guid transferDestinationId) => SessionAsync(ctx=>ctx.GetTransferDestinationById(transferDestinationId)); public TransferDestination? GetTransferDestinationById(Guid transferDestinationId) => Session(ctx => ctx.GetTransferDestinationById(transferDestinationId));
public Task<TransferDestination?> GetTransferDestinationByIdAsync(Guid transferDestinationId) => SessionAsync(ctx => ctx.GetTransferDestinationById(transferDestinationId));
public string? GetTransferDestinationJsonById(Guid transferDestinationId) => Session(ctx => ctx.GetTransferDestinationById(transferDestinationId)?.ToJson()); public string? GetTransferDestinationJsonById(Guid transferDestinationId) => Session(ctx => ctx.GetTransferDestinationById(transferDestinationId)?.ToJson());
public Task<bool> AddTransferDestinationAsync(TransferDestination transferDestination) => TransactionAsync(ctx => ctx.AddTransferDestination(transferDestination)); public Task<bool> AddTransferDestinationAsync(TransferDestination transferDestination) => TransactionAsync(ctx => ctx.AddTransferDestination(transferDestination));
public Task<bool> UpdateTransferDestinationAsync(TransferDestination transferDestination) => TransactionAsync(ctx => ctx.UpdateTransferDestination(transferDestination)); public Task<bool> UpdateTransferDestinationAsync(TransferDestination transferDestination) => TransactionAsync(ctx => ctx.UpdateTransferDestination(transferDestination));
public Task<bool> RemoveTransferDestinationAsync(TransferDestination transferDestination, bool removeAddress) => RemoveTransferDestinationAsync(transferDestination.Id, removeAddress); public Task<bool> RemoveTransferDestinationAsync(TransferDestination transferDestination, bool removeAddress) => RemoveTransferDestinationAsync(transferDestination.Id, removeAddress);
public Task<bool> RemoveTransferDestinationAsync(Guid transferDestinationId, bool removeAddress) => TransactionAsync(ctx => ctx.RemoveTransferDestination(transferDestinationId, removeAddress)); public Task<bool> RemoveTransferDestinationAsync(Guid transferDestinationId, bool removeAddress) => TransactionAsync(ctx => ctx.RemoveTransferDestination(transferDestinationId, removeAddress));
#endregion TransferDestination #endregion TransferDestination
#region TransferToDriver #region TransferToDriver
public Task<TransferToDriver?> GetTransferToDriverByIdAsync(Guid transferToDriverId, bool autoInclude = true) => SessionAsync(ctx => ctx.GetTransferToDriverById(transferToDriverId, autoInclude)); public Task<TransferToDriver?> GetTransferToDriverByIdAsync(Guid transferToDriverId, bool autoInclude = true) => SessionAsync(ctx => ctx.GetTransferToDriverById(transferToDriverId, autoInclude));
public Task<List<TransferToDriver>> GetTransferToDriversByTransferIdAsync(Guid transferId, bool autoInclude = true) => SessionAsync(ctx => ctx.GetTransferToDriversByTransferId(transferId, autoInclude).ToList()); public Task<List<TransferToDriver>> GetTransferToDriversByTransferIdAsync(Guid transferId, bool autoInclude = true) => SessionAsync(ctx => ctx.GetTransferToDriversByTransferId(transferId, autoInclude).ToList());
public Task<bool> AddTransferToDriverAsync(TransferToDriver transferToDriver) => TransactionAsync(ctx => ctx.AddTransferToDriver(transferToDriver)); public Task<bool> AddTransferToDriverAsync(TransferToDriver transferToDriver) => TransactionAsync(ctx => ctx.AddTransferToDriver(transferToDriver));
public Task<TransferToDriver?> UpdateTransferToDriverAsync(TransferToDriver transferToDriver) public Task<TransferToDriver?> UpdateTransferToDriverAsync(TransferToDriver transferToDriver)
=> UpdateSafeAsync(transferToDriver, (ctx, safeTransferToDriver) => ctx.UpdateTransferToDriver(safeTransferToDriver)); => UpdateSafeAsync(transferToDriver, (ctx, safeTransferToDriver) => ctx.UpdateTransferToDriver(safeTransferToDriver));
//public async Task<TransferToDriver?> UpdateTransferToDriverAsync(TransferToDriver transferToDriver) //public async Task<TransferToDriver?> UpdateTransferToDriverAsync(TransferToDriver transferToDriver)
//{ //{
@ -156,46 +162,53 @@ namespace TIAM.Database.DataLayers.Admins
//} //}
public Task<bool> RemoveTransferToDriverAsync(TransferToDriver transferToDriver) => TransactionAsync(ctx => ctx.RemoveTransferToDriver(transferToDriver.Id)); public Task<bool> RemoveTransferToDriverAsync(TransferToDriver transferToDriver) => TransactionAsync(ctx => ctx.RemoveTransferToDriver(transferToDriver.Id));
#endregion TransferToDriver #endregion TransferToDriver
#region Drivers #region Drivers
public Task<List<UserProductMapping>> GetAllDriversAsync(bool autoInclude = true) => SessionAsync(ctx => ctx.GetAllDrivers(autoInclude).ToList()); public Task<List<UserProductMapping>> GetAllDriversAsync(bool autoInclude = true) => SessionAsync(ctx => ctx.GetAllDrivers(autoInclude).ToList());
public Task<List<UserProductMapping>> GetAllDriversByProductIdAsync(Guid productId, bool autoInclude = true) => SessionAsync(ctx => ctx.GetAllDriversByProductId(productId, autoInclude).ToList()); public Task<List<UserProductMapping>> GetAllDriversByProductIdAsync(Guid productId, bool autoInclude = true) => SessionAsync(ctx => ctx.GetAllDriversByProductId(productId, autoInclude).ToList());
#endregion Drivers #endregion Drivers
#region TransferDestinationToProduct #region TransferDestinationToProduct
public TransferDestinationToProduct? GetTransferDestinationToProductById(Guid transferDestinationToProductId) => Session(ctx=>ctx.GetTransferDestinationToProductById(transferDestinationToProductId));
public Task<TransferDestinationToProduct?> GetTransferDestinationToProductByIdAsync(Guid transferDestinationToProductId) => SessionAsync(ctx=>ctx.GetTransferDestinationToProductById(transferDestinationToProductId)); public TransferDestinationToProduct? GetTransferDestinationToProductById(Guid transferDestinationToProductId) => Session(ctx => ctx.GetTransferDestinationToProductById(transferDestinationToProductId));
public Task<TransferDestinationToProduct?> GetTransferDestinationToProductByIdAsync(Guid transferDestinationToProductId) => SessionAsync(ctx => ctx.GetTransferDestinationToProductById(transferDestinationToProductId));
public string? GetTransferDestinationToProductJsonById(Guid transferDestinationToProductId) => Session(ctx => ctx.GetTransferDestinationToProductById(transferDestinationToProductId)?.ToJson()); public string? GetTransferDestinationToProductJsonById(Guid transferDestinationToProductId) => Session(ctx => ctx.GetTransferDestinationToProductById(transferDestinationToProductId)?.ToJson());
public TransferDestinationToProduct? GetTransferDestinationToProduct(Guid productId, Guid transferDestinationId) => Session(ctx=>ctx.GetTransferDestinationToProduct(productId, transferDestinationId)); public TransferDestinationToProduct? GetTransferDestinationToProduct(Guid productId, Guid transferDestinationId) => Session(ctx => ctx.GetTransferDestinationToProduct(productId, transferDestinationId));
public Task<List<TransferDestinationToProduct>> GetTransferDestinationToProducts() => SessionAsync(ctx=>ctx.GetTransferDestinationToProducts().ToList()); public Task<List<TransferDestinationToProduct>> GetTransferDestinationToProducts() => SessionAsync(ctx => ctx.GetTransferDestinationToProducts().ToList());
public Task<List<TransferDestinationToProduct>> GetTransferDestinationToProductsByProductId(Guid productId) => SessionAsync(ctx=>ctx.GetTransferDestinationToProductsByProductId(productId).ToList()); public Task<List<TransferDestinationToProduct>> GetTransferDestinationToProductsByProductId(Guid productId) => SessionAsync(ctx => ctx.GetTransferDestinationToProductsByProductId(productId).ToList());
public Task<List<TransferDestinationToProduct>> GetTransferDestinationToProductsByTransferDestinationId(Guid transferDestinationId) => SessionAsync(ctx=>ctx.GetTransferDestinationToProductsByTransferDestinationId(transferDestinationId).ToList()); public Task<List<TransferDestinationToProduct>> GetTransferDestinationToProductsByTransferDestinationId(Guid transferDestinationId) => SessionAsync(ctx => ctx.GetTransferDestinationToProductsByTransferDestinationId(transferDestinationId).ToList());
public string? GetTransferDestinationToProductJson(Guid productId, Guid transferDestinationId) => Session(ctx => ctx.GetTransferDestinationToProduct(productId, transferDestinationId)?.ToJson()); public string? GetTransferDestinationToProductJson(Guid productId, Guid transferDestinationId) => Session(ctx => ctx.GetTransferDestinationToProduct(productId, transferDestinationId)?.ToJson());
public Task<bool> AddTransferDestinationToProductAsync(TransferDestinationToProduct transferDestinationToProduct) => TransactionAsync(ctx => ctx.AddTransferDestinationToProduct(transferDestinationToProduct)); public Task<bool> AddTransferDestinationToProductAsync(TransferDestinationToProduct transferDestinationToProduct) => TransactionAsync(ctx => ctx.AddTransferDestinationToProduct(transferDestinationToProduct));
public Task<bool> UpdateTransferDestinationToProductAsync(TransferDestinationToProduct transferDestinationToProduct) => TransactionAsync(ctx => ctx.UpdateTransferDestinationToProduct(transferDestinationToProduct)); public Task<bool> UpdateTransferDestinationToProductAsync(TransferDestinationToProduct transferDestinationToProduct) => TransactionAsync(ctx => ctx.UpdateTransferDestinationToProduct(transferDestinationToProduct));
public Task<bool> RemoveTransferDestinationToProductAsync(TransferDestinationToProduct transferDestinationToProduct) => RemoveTransferDestinationToProductAsync(transferDestinationToProduct.Id); public Task<bool> RemoveTransferDestinationToProductAsync(TransferDestinationToProduct transferDestinationToProduct) => RemoveTransferDestinationToProductAsync(transferDestinationToProduct.Id);
public Task<bool> RemoveTransferDestinationToProductAsync(Guid transferDestinationToProductId) => TransactionAsync(ctx => ctx.RemoveTransferDestinationToProduct(transferDestinationToProductId)); public Task<bool> RemoveTransferDestinationToProductAsync(Guid transferDestinationToProductId) => TransactionAsync(ctx => ctx.RemoveTransferDestinationToProduct(transferDestinationToProductId));
#endregion TransferDestinationToProduct #endregion TransferDestinationToProduct
public User? GetUserById(Guid userId, bool autoInclude = false) => Session(ctx => ctx.GetUserById(userId, autoInclude)); public User? GetUserById(Guid userId, bool autoInclude = false) => Session(ctx => ctx.GetUserById(userId, autoInclude));
public User? GetUserByEmail(string email, bool autoInclude = false) => Session(ctx => ctx.GetUserByEmail(email, autoInclude)); public User? GetUserByEmail(string email, bool autoInclude = false) => Session(ctx => ctx.GetUserByEmail(email, autoInclude));
public TUserModelDto? GetUserModelDtoById<TUserModelDto>(Guid userId, bool onlyConfirmed) where TUserModelDto : class, IUserModelDtoMinBase public TUserModelDto? GetUserModelDtoById<TUserModelDto>(Guid userId, bool onlyConfirmed) where TUserModelDto : class, IUserModelDtoMinBase
=> Session(ctx => ctx.GetUserModelDtoById<TUserModelDto, User>(userId, onlyConfirmed)); => Session(ctx => ctx.GetUserModelDtoById<TUserModelDto, User>(userId, onlyConfirmed));
public Task<TUserModelDto?> GetUserModelDtoByIdAsync<TUserModelDto>(Guid userId, bool onlyConfirmed) where TUserModelDto : class, IUserModelDtoMinBase
public Task<TUserModelDto?> GetUserModelDtoByIdAsync<TUserModelDto>(Guid userId, bool onlyConfirmed) where TUserModelDto : class, IUserModelDtoMinBase
=> SessionAsync(ctx => ctx.GetUserModelDtoById<TUserModelDto, User>(userId, onlyConfirmed)); => SessionAsync(ctx => ctx.GetUserModelDtoById<TUserModelDto, User>(userId, onlyConfirmed));
public TUserModelDto? GetUserModelDtoByEmail<TUserModelDto>(string email, bool onlyConfirmed) where TUserModelDto : class, IUserModelDtoMinBase public TUserModelDto? GetUserModelDtoByEmail<TUserModelDto>(string email, bool onlyConfirmed) where TUserModelDto : class, IUserModelDtoMinBase
=> Session(ctx => ctx.GetUserModelDtoByEmail<TUserModelDto, User>(email, onlyConfirmed)); => Session(ctx => ctx.GetUserModelDtoByEmail<TUserModelDto, User>(email, onlyConfirmed));
public Task<TUserModelDto?> GetUserModelDtoByEmailAsync<TUserModelDto>(string email, bool onlyConfirmed) where TUserModelDto : class, IUserModelDtoMinBase
public Task<TUserModelDto?> GetUserModelDtoByEmailAsync<TUserModelDto>(string email, bool onlyConfirmed) where TUserModelDto : class, IUserModelDtoMinBase
=> SessionAsync(ctx => ctx.GetUserModelDtoByEmail<TUserModelDto, User>(email, onlyConfirmed)); => SessionAsync(ctx => ctx.GetUserModelDtoByEmail<TUserModelDto, User>(email, onlyConfirmed));
public string? GetUserJsonById(Guid userId, bool onlyConfirmed) => Session(ctx => ctx.GetUserById(userId, onlyConfirmed)?.ToJson()); public string? GetUserJsonById(Guid userId, bool onlyConfirmed) => Session(ctx => ctx.GetUserById(userId, onlyConfirmed)?.ToJson());
public string GetUsersJson() => Session(ctx => ctx.Users.ToJson()); public string GetUsersJson() => Session(ctx => ctx.Users.ToJson());
public Task<bool> AddUserAsync(User user) => TransactionAsync(ctx => ctx.AddUser(user)); public Task<bool> AddUserAsync(User user) => TransactionAsync(ctx => ctx.AddUser(user));
public Task<bool> UpdateUserAsync(User user) => TransactionAsync(ctx => ctx.UpdateUser(user)); public Task<bool> UpdateUserAsync(User user) => TransactionAsync(ctx => ctx.UpdateUser(user));
public Task<bool> RemoveUserAsync(Guid userId) => TransactionAsync(ctx => ctx.RemoveUser(userId)); public Task<bool> RemoveUserAsync(Guid userId) => TransactionAsync(ctx => ctx.RemoveUser(userId));
@ -234,7 +247,8 @@ namespace TIAM.Database.DataLayers.Admins
=> SessionAsync(x => x.GetPermissionContextsViewByContextId(contextId).ToList()); => SessionAsync(x => x.GetPermissionContextsViewByContextId(contextId).ToList());
#region UserProductMapping #region UserProductMapping
public Task<bool> AddUserProductMappingAsync(UserProductMapping userProductMapping)
public Task<bool> AddUserProductMappingAsync(UserProductMapping userProductMapping)
=> TransactionAsync(ctx => ctx.AddUserProductMapping(userProductMapping)); => TransactionAsync(ctx => ctx.AddUserProductMapping(userProductMapping));
public async Task<UserProductMapping?> AddUserProductMappingAsync(Guid userProductMappingId, Guid userId, Guid productId, int permissions = 1, UserProductJsonDetailModel? userProductToCars = null) public async Task<UserProductMapping?> AddUserProductMappingAsync(Guid userProductMappingId, Guid userId, Guid productId, int permissions = 1, UserProductJsonDetailModel? userProductToCars = null)
@ -244,7 +258,7 @@ namespace TIAM.Database.DataLayers.Admins
var isSucces = await TransactionAsync(ctx => var isSucces = await TransactionAsync(ctx =>
{ {
userProductMapping = ctx.AddUserProductMapping(userProductMappingId, userId, productId, permissions, userProductToCars); userProductMapping = ctx.AddUserProductMapping(userProductMappingId, userId, productId, permissions, userProductToCars);
return userProductMapping != null; return userProductMapping != null;
}); });
@ -253,14 +267,14 @@ namespace TIAM.Database.DataLayers.Admins
public Task<bool> UpdateUserProductMappingAsync(UserProductMapping userProductMapping) => TransactionAsync(ctx => ctx.UpdateUserProductMapping(userProductMapping)); public Task<bool> UpdateUserProductMappingAsync(UserProductMapping userProductMapping) => TransactionAsync(ctx => ctx.UpdateUserProductMapping(userProductMapping));
public async Task<UserProductMapping?> UpdateUserProductMappingAsync(Guid userProductMappingId, int permissions = 1, UserProductJsonDetailModel? userProductToCars = null) public async Task<UserProductMapping?> UpdateUserProductMappingAsync(Guid userProductMappingId, int permissions = 1, UserProductJsonDetailModel? userProductToCars = null)
{ {
UserProductMapping? userProductMapping = null; UserProductMapping? userProductMapping = null;
var isSucces = await TransactionAsync(ctx => var isSucces = await TransactionAsync(ctx =>
{ {
userProductMapping = ctx.UpdateUserProductMapping(userProductMappingId, permissions, userProductToCars); userProductMapping = ctx.UpdateUserProductMapping(userProductMappingId, permissions, userProductToCars);
return userProductMapping != null; return userProductMapping != null;
}); });
@ -273,39 +287,46 @@ namespace TIAM.Database.DataLayers.Admins
#endregion UserProductMapping #endregion UserProductMapping
#region Address #region Address
public Task<Address?> GetAddressByIdAsync(Guid addressId) => SessionAsync(ctx => ctx.GetAddressById(addressId)); public Task<Address?> GetAddressByIdAsync(Guid addressId) => SessionAsync(ctx => ctx.GetAddressById(addressId));
public Task<bool> UpdateAddressAsync(Address adress) => TransactionAsync(ctx => ctx.UpdateAddress(adress)); public Task<bool> UpdateAddressAsync(Address adress) => TransactionAsync(ctx => ctx.UpdateAddress(adress));
#endregion Address #endregion Address
#region Profile #region Profile
public Task<Profile?> GetProfileByIdAsync(Guid profileId) => SessionAsync(ctx => ctx.GetProfileById(profileId)); public Task<Profile?> GetProfileByIdAsync(Guid profileId) => SessionAsync(ctx => ctx.GetProfileById(profileId));
public Task<bool> UpdateProfileAsync(Profile profile) => TransactionAsync(ctx => ctx.UpdateProfile(profile)); public Task<bool> UpdateProfileAsync(Profile profile) => TransactionAsync(ctx => ctx.UpdateProfile(profile));
//public Task<bool> AddProfileAsync(Profile profile) => TransactionAsync(ctx => ctx.AddProfile(profile)); //Nem Add-olunk önmagában Profile-t! - J. //public Task<bool> AddProfileAsync(Profile profile) => TransactionAsync(ctx => ctx.AddProfile(profile)); //Nem Add-olunk önmagában Profile-t! - J.
//public Task<bool> RemoveProfileAsync(Guid profileId) => TransactionAsync(ctx => ctx.RemoveProfile(profileId)); //Nem törlünk Profile-t! - J. //public Task<bool> RemoveProfileAsync(Guid profileId) => TransactionAsync(ctx => ctx.RemoveProfile(profileId)); //Nem törlünk Profile-t! - J.
#endregion Profile #endregion Profile
#region EmailMessage #region EmailMessage
public Task<EmailMessage?> GetEmailMessageByIdAsync(Guid emailMessageId) => SessionAsync(ctx => ctx.GetEmailMessageById(emailMessageId)); public Task<EmailMessage?> GetEmailMessageByIdAsync(Guid emailMessageId) => SessionAsync(ctx => ctx.GetEmailMessageById(emailMessageId));
public Task<List<EmailMessage>> GetEmailMessagesByContextIdAsync(Guid contextId) => SessionAsync(ctx => ctx.GetEmailMessagesByContextId(contextId).OrderByDescending(x=>x.Created).ToList()); public Task<List<EmailMessage>> GetEmailMessagesByContextIdAsync(Guid contextId) => SessionAsync(ctx => ctx.GetEmailMessagesByContextId(contextId).OrderByDescending(x => x.Created).ToList());
public Task<List<EmailMessage>> GetEmailMessagesBySenderIdAsync(Guid senderId) => SessionAsync(ctx => ctx.GetEmailMessagesBySenderId(senderId).OrderByDescending(x=>x.Created).ToList()); public Task<List<EmailMessage>> GetEmailMessagesBySenderIdAsync(Guid senderId) => SessionAsync(ctx => ctx.GetEmailMessagesBySenderId(senderId).OrderByDescending(x => x.Created).ToList());
public Task<List<EmailMessage>> GetEmailMessagesBySenderEmailAddressAsync(string emailAddress) => SessionAsync(ctx => ctx.GetEmailMessagesBySenderEmailAddress(emailAddress).OrderByDescending(x=>x.Created).ToList()); public Task<List<EmailMessage>> GetEmailMessagesBySenderEmailAddressAsync(string emailAddress) => SessionAsync(ctx => ctx.GetEmailMessagesBySenderEmailAddress(emailAddress).OrderByDescending(x => x.Created).ToList());
public Task<List<EmailMessage>> GetEmailMessagesAsync(Guid userId, Guid userProductMappingId) => SessionAsync(ctx => ctx.GetEmailMessages<EmailMessage, EmailRecipient>(userId, userProductMappingId).OrderByDescending(x=>x.Created).ToList()); public Task<List<EmailMessage>> GetEmailMessagesAsync(Guid userId, Guid userProductMappingId) => SessionAsync(ctx => ctx.GetEmailMessages<EmailMessage, EmailRecipient>(userId, userProductMappingId).OrderByDescending(x => x.Created).ToList());
public Task<List<EmailMessage>> GetEmailMessagesAsync(Guid contextId, Guid userId, Guid userProductMappingId) => SessionAsync(ctx => ctx.GetEmailMessages<EmailMessage, EmailRecipient>(contextId, userId, userProductMappingId).OrderByDescending(x=>x.Created).ToList()); public Task<List<EmailMessage>> GetEmailMessagesAsync(Guid contextId, Guid userId, Guid userProductMappingId) => SessionAsync(ctx => ctx.GetEmailMessages<EmailMessage, EmailRecipient>(contextId, userId, userProductMappingId).OrderByDescending(x => x.Created).ToList());
public Task<List<EmailMessage>> GetAllEmailMessagesAsync() => SessionAsync(ctx => ctx.GetAllEmailMessages<EmailMessage, EmailRecipient>().OrderByDescending(x=>x.Created).ToList()); public Task<List<EmailMessage>> GetAllEmailMessagesAsync() => SessionAsync(ctx => ctx.GetAllEmailMessages<EmailMessage, EmailRecipient>().OrderByDescending(x => x.Created).ToList());
public Task<bool> AddEmailMessageAsync(EmailMessage emailMessage) public Task<bool> AddEmailMessageAsync(EmailMessage emailMessage)
=> TransactionAsync(ctx => ctx.AddEmailMessage(emailMessage)); => TransactionAsync(ctx => ctx.AddEmailMessage(emailMessage));
public Task<bool> UpdateEmailMessageAsync(EmailMessage emailMessage) public Task<bool> UpdateEmailMessageAsync(EmailMessage emailMessage)
=> TransactionAsync(ctx => ctx.UpdateEmailMessage(emailMessage)); => TransactionAsync(ctx => ctx.UpdateEmailMessage(emailMessage));
public Task<bool> RemoveEmailMessageAsync(Guid emailMessageId) public Task<bool> RemoveEmailMessageAsync(Guid emailMessageId)
=> TransactionAsync(ctx => ctx.RemoveEmailMessage(emailMessageId)); => TransactionAsync(ctx => ctx.RemoveEmailMessage(emailMessageId));
#endregion EmailMessage #endregion EmailMessage
#region ServiceProviders #region ServiceProviders
//15. (IServiceProviderDataService) Create service provider //15. (IServiceProviderDataService) Create service provider
public Task<bool> AddCompanyAsync(Company serviceProvider) => TransactionAsync(ctx => ctx.AddCompany<Company, Profile, Address>(serviceProvider)); public Task<bool> AddCompanyAsync(Company serviceProvider) => TransactionAsync(ctx => ctx.AddCompany<Company, Profile, Address>(serviceProvider));
@ -313,7 +334,7 @@ namespace TIAM.Database.DataLayers.Admins
public Task<string> GetCompaniesJsonAsync() => SessionAsync(ctx => ctx.Companies.ToJson()); public Task<string> GetCompaniesJsonAsync() => SessionAsync(ctx => ctx.Companies.ToJson());
public string GetCompaniesJson() => Session(ctx => ctx.Companies.ToJson()); public string GetCompaniesJson() => Session(ctx => ctx.Companies.ToJson());
public virtual Task<Company?> GetCompanyByIdAsync(Guid id) => SessionAsync(ctx => ctx.GetCompanyById(id)); public virtual Task<Company?> GetCompanyByIdAsync(Guid id) => SessionAsync(ctx => ctx.GetCompanyById(id));
public virtual Task<List<Company>> GetCompaniesByOwnerIdAsync(Guid id) => SessionAsync(ctx => ctx.GetCompaniesByOwnerId(id)); public virtual Task<List<Company>> GetCompaniesByOwnerIdAsync(Guid id) => SessionAsync(ctx => ctx.GetCompaniesByOwnerId(id));
@ -326,10 +347,12 @@ namespace TIAM.Database.DataLayers.Admins
//14. (IserviceProviderDataService) Update service provider //14. (IserviceProviderDataService) Update service provider
public Task<bool> UpdateCompanyAsync(Company company) => TransactionAsync(ctx => ctx.UpdateCompany(company)); public Task<bool> UpdateCompanyAsync(Company company) => TransactionAsync(ctx => ctx.UpdateCompany(company));
//13. (IserviceProviderDataService) delete service provider //13. (IserviceProviderDataService) delete service provider
public Task<bool> RemoveCompanyAsync(Guid companyId) => TransactionAsync(ctx => ctx.RemoveProductsByCompanyId(companyId) && ctx.RemoveCompany(companyId)); public Task<bool> RemoveCompanyAsync(Guid companyId) => TransactionAsync(ctx => ctx.RemoveProductsByCompanyId(companyId) && ctx.RemoveCompany(companyId));
//public Task<bool> RemoveCompanyAsync(Company company) => RemoveCompanyAsync(company.Id); //public Task<bool> RemoveCompanyAsync(Company company) => RemoveCompanyAsync(company.Id);
#endregion #endregion
#region PermissionTypes #region PermissionTypes
@ -364,6 +387,7 @@ namespace TIAM.Database.DataLayers.Admins
{ {
nextBitValue = Math.Pow(2, 0); nextBitValue = Math.Pow(2, 0);
} }
permissionsType.PermissionBit = (int)nextBitValue; permissionsType.PermissionBit = (int)nextBitValue;
Context.PermissionsTypes.Add(permissionsType); Context.PermissionsTypes.Add(permissionsType);
Context.SaveChanges(); Context.SaveChanges();
@ -376,6 +400,7 @@ namespace TIAM.Database.DataLayers.Admins
} }
} }
return Task.FromResult(result); return Task.FromResult(result);
} }
@ -465,6 +490,7 @@ namespace TIAM.Database.DataLayers.Admins
{ {
GlobalLogger.Info($@"GetPermissionsOfUserProductMappingsAndGroupsAsyncByContextId: {row.ContextId}, {row.SubjectId}, {row.SubjectType}, {row.Name}, {row.PermissionsValue}"); GlobalLogger.Info($@"GetPermissionsOfUserProductMappingsAndGroupsAsyncByContextId: {row.ContextId}, {row.SubjectId}, {row.SubjectType}, {row.Name}, {row.PermissionsValue}");
} }
return Task.FromResult(result); return Task.FromResult(result);
} }
@ -500,6 +526,7 @@ namespace TIAM.Database.DataLayers.Admins
transaction.Commit(); transaction.Commit();
result = true; result = true;
} }
return Task.FromResult(result); return Task.FromResult(result);
} }
@ -534,6 +561,7 @@ namespace TIAM.Database.DataLayers.Admins
result = false; result = false;
} }
} }
return Task.FromResult(result); return Task.FromResult(result);
} }
@ -635,9 +663,9 @@ namespace TIAM.Database.DataLayers.Admins
#region Logs #region Logs
public Task<List<AcLogItem>> GetLogItemsAsync(int takeCount = 100) => SessionAsync(ctx => ctx.LogItems.Where(x=>x.LogLevel != LogLevel.Debug && x.LogLevel != LogLevel.Trace && x.LogLevel != LogLevel.Detail).Take(takeCount).ToList()); public Task<List<AcLogItem>> GetLogItemsAsync(int takeCount = 500) => SessionAsync(ctx => ctx.LogItems.Take(takeCount).ToList());
public Task<List<AcLogItem>> GetLogItemsByFilterAsync(CriteriaOperator criteriaOperator, int takeCount = 500) => SessionAsync(ctx => (ctx.LogItems.AppendWhere(new CriteriaToExpressionConverter(), criteriaOperator).Take(takeCount) as IQueryable<AcLogItem>)!.ToList());
#endregion #endregion
} }
} }

View File

@ -14,15 +14,15 @@ public static class TransferDbSetExtensions
public static bool UpdateTransfer(this ITransferDbSet ctx, Transfer transfer) public static bool UpdateTransfer(this ITransferDbSet ctx, Transfer transfer)
=> ctx.Transfers.Update(transfer).State == EntityState.Modified; => ctx.Transfers.Update(transfer).State == EntityState.Modified;
public static bool UpdateTransferStatus(this ITransferDbSet ctx, Guid transferId, TransferStatusType transferStatusType) public static bool UpdateTransferStatus(this ITransferDbSet ctx, Guid transferId, TransferStatusType transferStatusType, bool onlyStatusLowerThanNew = true)
{ {
var transfer = ctx.Transfers.FirstOrDefault(x => x.Id == transferId); var transfer = ctx.Transfers.FirstOrDefault(x => x.Id == transferId);
return transfer != null && ctx.UpdateTransferStatus(transfer, transferStatusType); return transfer != null && ctx.UpdateTransferStatus(transfer, transferStatusType);
} }
public static bool UpdateTransferStatus(this ITransferDbSet ctx, Transfer transfer, TransferStatusType transferStatusType) public static bool UpdateTransferStatus(this ITransferDbSet ctx, Transfer transfer, TransferStatusType transferStatusType, bool onlyStatusLowerThanNew = true)
{ {
if (transfer.TransferStatusType == transferStatusType) return true; if (transfer.TransferStatusType == transferStatusType || (onlyStatusLowerThanNew && transfer.TransferStatusType > transferStatusType)) return true;
transfer.TransferStatusType = transferStatusType; transfer.TransferStatusType = transferStatusType;
return ctx.Transfers.Update(transfer).State == EntityState.Modified; return ctx.Transfers.Update(transfer).State == EntityState.Modified;

View File

@ -2,6 +2,7 @@
using AyCode.Interfaces.TimeStampInfo; using AyCode.Interfaces.TimeStampInfo;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization;
using AyCode.Interfaces.Profiles.Dtos; using AyCode.Interfaces.Profiles.Dtos;
using TIAM.Core.Enums; using TIAM.Core.Enums;
using TIAM.Entities.Products; using TIAM.Entities.Products;
@ -30,7 +31,9 @@ public class Transfer: IEntityGuid, IAcFullName, ITimeStampInfo, IProductForeign
public string? PaymentId { get; set; } public string? PaymentId { get; set; }
//public virtual UserProductMapping? UserProductMapping { get; set; } //public virtual UserProductMapping? UserProductMapping { get; set; }
public virtual List<TransferToDriver> TransferToDrivers { get; set; } [JsonIgnore]
[Newtonsoft.Json.JsonIgnore]
public virtual List<TransferToDriver> TransferToDrivers { get; set; } = [];
[Required] public TransferStatusType TransferStatusType { get; set; } = TransferStatusType.OrderSubmitted; [Required] public TransferStatusType TransferStatusType { get; set; } = TransferStatusType.OrderSubmitted;

View File

@ -95,6 +95,6 @@ public class SignalRTags : AcSignalRTags
public const int GetTransferDestinationToProductsByProductId = 95; public const int GetTransferDestinationToProductsByProductId = 95;
public const int GetTransferDestinationToProductsByTransferDestinationId = 96; public const int GetTransferDestinationToProductsByTransferDestinationId = 96;
public const int GetAllLogItems = 100; public const int GetAllLogItemsByFilterText = 100;
} }

View File

@ -14,6 +14,9 @@
@using AyCode.Services.Loggers @using AyCode.Services.Loggers
@using AyCode.Core @using AyCode.Core
@using AyCode.Core.Extensions @using AyCode.Core.Extensions
@using Castle.Components.DictionaryAdapter
@using DevExpress.Data.Filtering
@using TIAM.Core.Enums
@inject IServiceProviderDataService ServiceProviderDataService @inject IServiceProviderDataService ServiceProviderDataService
@inject IEnumerable<IAcLogWriterClientBase> LogWriters @inject IEnumerable<IAcLogWriterClientBase> LogWriters
@inject AdminSignalRClient AdminSignalRClient @inject AdminSignalRClient AdminSignalRClient
@ -25,10 +28,12 @@
<LogViewerGrid Logger="_logger" <LogViewerGrid Logger="_logger"
@ref="_logViewerGrid" @ref="_logViewerGrid"
SignalRClient="AdminSignalRClient" SignalRClient="AdminSignalRClient"
FilterText="@_filterText"
ShowGroupPanel="true" ShowGroupPanel="true"
PageSize="25" PageSize="20"
PagerPosition="GridPagerPosition.TopAndBottom"
PageSizeSelectorVisible="true" PageSizeSelectorVisible="true"
PageSizeSelectorItems="@(new int[] { 25, 50, 100, 200, 300, 400, 500 })" PageSizeSelectorItems="@(new int[] { 20, 50, 100, 200, 300, 400, 500 })"
PageSizeSelectorAllRowsItemVisible="true" PageSizeSelectorAllRowsItemVisible="true"
ValidationEnabled="false" ValidationEnabled="false"
CustomizeElement="Grid_CustomizeElement" CustomizeElement="Grid_CustomizeElement"
@ -51,18 +56,26 @@
var a = ((LogItemViewerModel)context.DataItem); var a = ((LogItemViewerModel)context.DataItem);
} }
<div>@($"{a.CategoryName}->{a.CallerName}")</div> <div>@($"{a.CategoryName}->{a.CallerName}")</div>
<div>@($"{a.Text}")</div><br/> <div>@($"{a.Text}")</div><br />
<div style="font-weight: bold;">Exception:</div> <div style="font-weight: bold;">Exception:</div>
<div style="word-wrap: break-word;">@a.Exception</div> <div style="word-wrap: break-word;">@a.Exception</div>
</DetailRowTemplate> </DetailRowTemplate>
<ToolbarTemplate>
<div>
<DxTagBox Data="@(Enum.GetValues<LogLevel>().ToList())" Values="@_selectedLogLevels"
NullText="Select status type..." ClearButtonDisplayMode="DataEditorClearButtonDisplayMode.Auto" aria-label="Select status type"
ValuesChanged="(IEnumerable<LogLevel> values) => TagBox_ValuesChanged(values)" />
</div>
</ToolbarTemplate>
</LogViewerGrid> </LogViewerGrid>
@code { @code {
[Parameter] public GridDetailExpandButtonDisplayMode DetailExpandButtonDisplayMode { get; set; } = GridDetailExpandButtonDisplayMode.Never; [Parameter] public GridDetailExpandButtonDisplayMode DetailExpandButtonDisplayMode { get; set; } = GridDetailExpandButtonDisplayMode.Never;
private LoggerClient<LogViewerGridComponent> _logger;
private LogViewerGrid _logViewerGrid; private LogViewerGrid _logViewerGrid;
private LoggerClient<LogViewerGridComponent> _logger;
private static List<LogLevel> _selectedLogLevels = [LogLevel.Error, LogLevel.Warning, LogLevel.Suggest];
private static string _filterText = GetFilterText(_selectedLogLevels);
protected override void OnInitialized() protected override void OnInitialized()
{ {
@ -71,11 +84,31 @@
base.OnInitialized(); base.OnInitialized();
} }
private static string GetFilterText(ICollection<LogLevel> selectedLogLevels)
=> selectedLogLevels.Count == 0 ? string.Empty : CriteriaOperator.FromLambda<LogItemViewerModel>(t => selectedLogLevels.Contains(t.LogLevel)).ToString();
void TagBox_ValuesChanged(IEnumerable<LogLevel> newSelectedLogLevels)
{
var filterText = string.Empty;
InOperator? filterCriteria = null;
_selectedLogLevels = newSelectedLogLevels.ToList();
if (_selectedLogLevels.Count > 0)
{
filterCriteria = new InOperator(nameof(LogLevel), _selectedLogLevels);
filterText = GetFilterText(_selectedLogLevels);
}
_filterText = filterText;
_logViewerGrid.SetFieldFilterCriteria(nameof(LogLevel), filterCriteria);
}
void Grid_CustomizeElement(GridCustomizeElementEventArgs e) void Grid_CustomizeElement(GridCustomizeElementEventArgs e)
{ {
if (e.ElementType != GridElementType.DataRow) return; if (e.ElementType != GridElementType.DataRow) return;
var logLevelObject = e.Grid?.GetRowValue(e.VisibleIndex, "LogLevel"); var logLevelObject = e.Grid?.GetRowValue(e.VisibleIndex, nameof(LogLevel));
if (logLevelObject == null) return; if (logLevelObject == null) return;
var levelObject = (LogLevel)logLevelObject; var levelObject = (LogLevel)logLevelObject;

View File

@ -199,8 +199,8 @@
<div> <div>
<DxTagBox Data="@Statuses" Values="@_selectedCategories" @ref="_filterTag" <DxTagBox Data="@Statuses" Values="@_selectedCategories" @ref="_filterTag"
ValuesChanged="(IEnumerable<TransferStatusModel> values) => TagBox_ValuesChanged(values)" ValuesChanged="(IEnumerable<TransferStatusModel> values) => TagBox_ValuesChanged(values)"
ValueFieldName="StatusValue" TextFieldName="StatusName" NullText="Select category..." ValueFieldName="StatusValue" TextFieldName="StatusName" NullText="Select status type..."
ClearButtonDisplayMode="DataEditorClearButtonDisplayMode.Auto" aria-label="Select category" /> ClearButtonDisplayMode="DataEditorClearButtonDisplayMode.Auto" aria-label="Select status type" />
</div> </div>
</ToolbarTemplate> </ToolbarTemplate>
</TransferGrid> </TransferGrid>
@ -254,21 +254,21 @@
"ContextId", "ContextId",
]; ];
private static List<TransferStatusModel> Statuses = private static readonly List<TransferStatusModel> Statuses =
[ [
new(Convert.ToByte(TransferStatusType.OrderSubmitted), "Order submitted"), new(Convert.ToByte(TransferStatusType.OrderSubmitted), "Order submitted"),
new(Convert.ToByte(TransferStatusType.OrderConfirmed), "Order confirmed"), new(Convert.ToByte(TransferStatusType.OrderConfirmed), "Order confirmed"),
new(Convert.ToByte(TransferStatusType.AssignedToDriver), "Assigned to driver"), new(Convert.ToByte(TransferStatusType.AssignedToDriver), "Assigned to driver"),
new(Convert.ToByte(TransferStatusType.DriverConfirmed), "Driver confirmed"), new(Convert.ToByte(TransferStatusType.DriverConfirmed), "Driver confirmed"),
new(Convert.ToByte(TransferStatusType.DriverEnRoute), "Driver enroute"), new(Convert.ToByte(TransferStatusType.DriverEnRoute), "Driver enroute"),
new(Convert.ToByte(TransferStatusType.PassengerPickup), "Passenger in car"), new(Convert.ToByte(TransferStatusType.PassengerPickup), "Passenger in car"),
new(Convert.ToByte(TransferStatusType.Finished), "Finished"), new(Convert.ToByte(TransferStatusType.Finished), "Finished"),
new(Convert.ToByte(TransferStatusType.UserCanceled), "User cancelled"), new(Convert.ToByte(TransferStatusType.UserCanceled), "User cancelled"),
new(Convert.ToByte(TransferStatusType.AdminDenied), "Admin cancelled") new(Convert.ToByte(TransferStatusType.AdminDenied), "Admin cancelled")
]; ];
private static List<TransferStatusModel> _selectedCategories = Statuses.Where(x => /* x.StatusValue != (byte)TransferStatusType.OrderSubmitted && */ x.StatusValue != (byte)TransferStatusType.Finished && x.StatusValue != (byte)TransferStatusType.UserCanceled && x.StatusValue != (byte)TransferStatusType.AdminDenied).ToList(); private static List<TransferStatusModel> _selectedCategories = Statuses.Where(x => /* x.StatusValue != (byte)TransferStatusType.OrderSubmitted && */ x.StatusValue != (byte)TransferStatusType.Finished && x.StatusValue != (byte)TransferStatusType.UserCanceled && x.StatusValue != (byte)TransferStatusType.AdminDenied).ToList();
private string? _filterText = GetFilterText(_selectedCategories.Select(x => (TransferStatusType)x.StatusValue).ToList()); private string _filterText = GetFilterText(_selectedCategories.Select(x => (TransferStatusType)x.StatusValue).ToList());
private MessageWizardModel _messageWizardModel = new(); private MessageWizardModel _messageWizardModel = new();
@ -392,12 +392,12 @@
transferEditModel.ContactEmail = "your@email.address"; transferEditModel.ContactEmail = "your@email.address";
} }
private static string? GetFilterText(ICollection<TransferStatusType> selectedTransferStatuses) private static string GetFilterText(ICollection<TransferStatusType> selectedTransferStatuses)
=> selectedTransferStatuses.Count == 0 ? null : CriteriaOperator.FromLambda<Transfer>(t => selectedTransferStatuses.Contains(t.TransferStatusType)).ToString(); => selectedTransferStatuses.Count == 0 ? string.Empty : CriteriaOperator.FromLambda<Transfer>(t => selectedTransferStatuses.Contains(t.TransferStatusType)).ToString();
void TagBox_ValuesChanged(IEnumerable<TransferStatusModel> newSelectedCategories) void TagBox_ValuesChanged(IEnumerable<TransferStatusModel> newSelectedCategories)
{ {
string? filterText = null; var filterText = string.Empty;
InOperator? filterCriteria = null; InOperator? filterCriteria = null;
_selectedCategories = newSelectedCategories.ToList(); _selectedCategories = newSelectedCategories.ToList();

View File

@ -40,7 +40,7 @@
</CellDisplayTemplate> </CellDisplayTemplate>
</DxGridDataColumn> </DxGridDataColumn>
<DxGridDataColumn FieldName="IsReaded" Caption="Readed" Width="70" CaptionAlignment="GridTextAlignment.Center" TextAlignment="GridTextAlignment.Center" /> <DxGridDataColumn FieldName="IsReaded" Caption="Readed" Width="70" CaptionAlignment="GridTextAlignment.Center" TextAlignment="GridTextAlignment.Center" />
<DxGridDataColumn FieldName="Created" DisplayFormat="g" Width="100" SortIndex="0" SortOrder="GridColumnSortOrder.Descending" CaptionAlignment="GridTextAlignment.Center" TextAlignment="GridTextAlignment.Center" /> <DxGridDataColumn FieldName="Created" DisplayFormat="g" Width="130" SortIndex="0" SortOrder="GridColumnSortOrder.Descending" CaptionAlignment="GridTextAlignment.Center" TextAlignment="GridTextAlignment.Center" />
</Columns> </Columns>
<DetailRowTemplate> <DetailRowTemplate>
@{ @{

View File

@ -39,7 +39,7 @@
<DxGridDataColumn FieldName="Latitude" Width="40" /> <DxGridDataColumn FieldName="Latitude" Width="40" />
<DxGridDataColumn FieldName="Longitude" Width="40" /> <DxGridDataColumn FieldName="Longitude" Width="40" />
<DxGridDataColumn FieldName="IsReaded" Caption="Readed" Width="70" CaptionAlignment="GridTextAlignment.Center" TextAlignment="GridTextAlignment.Center" /> <DxGridDataColumn FieldName="IsReaded" Caption="Readed" Width="70" CaptionAlignment="GridTextAlignment.Center" TextAlignment="GridTextAlignment.Center" />
<DxGridDataColumn FieldName="Created" DisplayFormat="g" Width="100" SortIndex="0" SortOrder="GridColumnSortOrder.Descending" CaptionAlignment="GridTextAlignment.Center" TextAlignment="GridTextAlignment.Center" /> <DxGridDataColumn FieldName="Created" DisplayFormat="g" Width="130" SortIndex="0" SortOrder="GridColumnSortOrder.Descending" CaptionAlignment="GridTextAlignment.Center" TextAlignment="GridTextAlignment.Center" />
</Columns> </Columns>
<DetailRowTemplate> <DetailRowTemplate>

View File

@ -11,7 +11,7 @@ public class LogViewerGrid : TiamGrid<LogItemViewerModel>
{ {
public LogViewerGrid() : base() public LogViewerGrid() : base()
{ {
GetAllMessageTag = SignalRTags.GetAllLogItems; GetAllMessageTag = SignalRTags.GetAllLogItemsByFilterText;
} }
protected override Task SetParametersAsyncCore(ParameterView parameters) protected override Task SetParametersAsyncCore(ParameterView parameters)

View File

@ -1,10 +1,14 @@
using AyCode.Core.Consts; using AyCode.Core.Consts;
using AyCode.Entities;
using AyCode.Entities.Server.LogItems; using AyCode.Entities.Server.LogItems;
using AyCode.Services.SignalRs; using AyCode.Services.SignalRs;
using AyCode.Utils.Extensions;
using DevExpress.Data.Filtering;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Cors; using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using TIAM.Database.DataLayers.Admins; using TIAM.Database.DataLayers.Admins;
using TIAM.Entities.Transfers;
using TIAM.Services; using TIAM.Services;
using TIAMWebApp.Server.Services; using TIAMWebApp.Server.Services;
using TIAMWebApp.Shared.Application.Models; using TIAMWebApp.Shared.Application.Models;
@ -52,16 +56,18 @@ namespace TIAMWebApp.Server.Controllers
[AllowAnonymous] [AllowAnonymous]
[HttpGet] [HttpGet]
[Route(APIUrls.GetAllLogItemsRouteName)] [Route(APIUrls.GetAllLogItemsRouteName)]
[SignalR(SignalRTags.GetAllLogItems)] [SignalR(SignalRTags.GetAllLogItemsByFilterText)]
public async Task<List<LogItemViewerModel>> GetAllLogItems()//(int takeCount, string filterText) public async Task<List<LogItemViewerModel>> GetAllLogItems(string? criteriaOperatorText) //(int takeCount, string filterText)
{ {
var logItemList = await adminDal.GetLogItemsAsync(1000); //public Task<List<Transfer>> GetTransfersByFilterAsync(CriteriaOperator criteriaOperator) => SessionAsync(ctx => (ctx.GetTransfers().AppendWhere(new CriteriaToExpressionConverter(), criteriaOperator) as IQueryable<Transfer>)!.ToList());
var resultList = new List<LogItemViewerModel>(logItemList.Count); List<AcLogItem> logItemList;
foreach (var logItem in logItemList) if (criteriaOperatorText.IsNullOrWhiteSpace()) logItemList = await adminDal.GetLogItemsAsync(1000);
{ else logItemList = await adminDal.GetLogItemsByFilterAsync(CriteriaOperator.Parse(criteriaOperatorText),1000);
resultList.Add(new LogItemViewerModel(Guid.NewGuid(), logItem, logItem.LogHeaderId));
} var resultList = new List<LogItemViewerModel>(logItemList.Count);
//logItemList[0].ToModelDto<LogItemViewerModel, AcLogItem>();
resultList.AddRange(logItemList.Select(logItem => new LogItemViewerModel(logItem, logItem.LogHeaderId)));
return resultList; return resultList;
} }

View File

@ -8,21 +8,21 @@ using System.ComponentModel.DataAnnotations.Schema;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using AyCode.Interfaces;
namespace TIAMWebApp.Shared.Application.Models.ClientSide.UI namespace TIAMWebApp.Shared.Application.Models.ClientSide.UI
{ {
//[Table("LogItem")] //[Table("LogItem")]
public class LogItemViewerModel : AcLogItemClient, IId<Guid> public class LogItemViewerModel : AcLogItemClient, IId<Guid>, IAcModelDtoBase
{ {
public Guid Id { get ; set; } public Guid Id { get ; set; } = Guid.NewGuid();
public int LogHeaderId { get; set; } public int LogHeaderId { get; set; }
public LogItemViewerModel() public LogItemViewerModel()
{} {}
public LogItemViewerModel(Guid id, IAcLogItemClient logItemClient, int logHeaderId) { public LogItemViewerModel(IAcLogItemClient logItemClient, int logHeaderId) {
Id = id;
TimeStampUtc = logItemClient.TimeStampUtc; TimeStampUtc = logItemClient.TimeStampUtc;
AppType = logItemClient.AppType; AppType = logItemClient.AppType;
LogLevel= logItemClient.LogLevel; LogLevel= logItemClient.LogLevel;