SHA256
GuestLog - General Improvements.
- GuestDocument details - Added navigation to details for stays. - StayEntry details - Added dialog to see details of GuestDocuments. - StayEntry List - Added filter for result table. - StayEntry New - Show suggested guests on GuestSearchDialog so no searchs are required in some cases. - NavMenu - Removed default navigation links.
This commit is contained in:
@@ -12,6 +12,7 @@ public interface IStayEntryService
|
||||
|
||||
public Task<StayEntryDTO?> GetDtoByIdAsync(long id, StayEntryQueryConfig? queryConfig = null);
|
||||
public Task<IEnumerable<StayEntryDTO>> GetDtoListAsync(StayEntryQueryConfig? queryConfig = null);
|
||||
public Task<IEnumerable<StayEntryDTO>> GetDtoListByFilterAsync(StayEntryFilterDTO filter, int limit = 0, StayEntryQueryConfig? queryConfig = null);
|
||||
|
||||
|
||||
public Task<bool> IsGuestInStayInPeriod(string docType, string docNum, DateTime startTime, DateTime endTime);
|
||||
|
||||
@@ -5,6 +5,7 @@ using Somnia.GuestLog.Models;
|
||||
using Somnia.GuestLog.Models.DTOs;
|
||||
using Somnia.GuestLog.Models.Entities;
|
||||
using Somnia.GuestLog.Models.QueryConfigs;
|
||||
using Somnia.GuestLog.Utils;
|
||||
|
||||
namespace Somnia.GuestLog.Services;
|
||||
|
||||
@@ -135,6 +136,32 @@ public class StayEntryService(
|
||||
return dbList.Select(e => GetDtoFromDb(e, queryConfig));
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<StayEntryDTO>> GetDtoListByFilterAsync(StayEntryFilterDTO filter, int limit = 0, StayEntryQueryConfig? queryConfig = null)
|
||||
{
|
||||
using var dbContext = contextFactory.CreateDbContext();
|
||||
|
||||
var query = dbContext.StayEntries
|
||||
.AddQueryConfig(queryConfig)
|
||||
.AsQueryable();
|
||||
|
||||
query = query.WhereIf(filter.DateInStart is not null && filter.DateInEnd is not null,
|
||||
e => e.DateIn >= filter.DateInStart!.Value.ToUniversalTime()
|
||||
&& e.DateIn < filter.DateInEnd!.Value.ToUniversalTime());
|
||||
query = query.WhereIf(!string.IsNullOrEmpty(filter.RoomNumber),
|
||||
e => EF.Functions.Like(e.RoomNumber, $"%{filter.RoomNumber}%"));
|
||||
query = query.WhereIf(!string.IsNullOrEmpty(filter.PaymentMethod),
|
||||
e => e.PaymentMethod == filter.PaymentMethod);
|
||||
|
||||
if (limit > 0)
|
||||
{
|
||||
query = query.Take(limit);
|
||||
}
|
||||
|
||||
var dbList = await query.ToListAsync();
|
||||
|
||||
return dbList.Select(x => GetDtoFromDb(x, queryConfig));
|
||||
}
|
||||
|
||||
|
||||
public async Task<bool> IsGuestInStayInPeriod(string docType, string docNum, DateTime startTime, DateTime endTime)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user