SHA256
- Details/New - Fixed time field binding. Now it binds directly to the Model instead of using temp TimeSpans. - New - Fixed StayEntry validation to allow creating Stays with a DateOut in the past. - List - Added ordering to db results so limit behaves in a deterministic way. Fixed default search so stays created today are shown.
53 lines
1.9 KiB
C#
53 lines
1.9 KiB
C#
using Somnia.GuestLog.Models.DTOs;
|
|
using Somnia.GuestLog.Models.Entities;
|
|
|
|
namespace Somnia.GuestLog.Models;
|
|
|
|
internal static class EntityMapping
|
|
{
|
|
|
|
public static GuestDocumentDTO MapGuestDocumentEntityToDTO(GuestDocument entity)
|
|
{
|
|
return new()
|
|
{
|
|
DocumentType = entity.DocumentType,
|
|
DocumentNum = entity.DocumentNum,
|
|
IssueDate = entity.IssueDate.ToDateTime(TimeOnly.MinValue),
|
|
SupportNum = entity.SupportNum,
|
|
Nationality = entity.Nationality,
|
|
Name = entity.Name,
|
|
Surname = entity.Surname,
|
|
Surname2 = entity.Surname2,
|
|
BirthDate = entity.BirthDate.ToDateTime(TimeOnly.MinValue),
|
|
Gender = entity.Gender,
|
|
PhoneNumber = entity.PhoneNumber,
|
|
EmailAddress = entity.EmailAddress,
|
|
Address = entity.AddressDetails?.Address ?? "",
|
|
AddressCity = entity.AddressDetails?.AddressCity ?? "",
|
|
AddressProvince = entity.AddressDetails?.AddressProvince ?? "",
|
|
AddressState = entity.AddressDetails?.AddressState ?? "",
|
|
AddressCountry = entity.AddressDetails?.AddressCountry! ?? "",
|
|
ZipCode = entity.AddressDetails?.ZipCode ?? "",
|
|
CreateTime = entity.CreateTime,
|
|
UpdateTime = entity.UpdateTime,
|
|
};
|
|
}
|
|
|
|
public static StayEntryDTO MapStayEntryEntityToDTO(StayEntry entity, bool includeGuests)
|
|
{
|
|
return new()
|
|
{
|
|
Id = entity.Id,
|
|
DateIn = entity.DateIn.ToLocalTime(),
|
|
DateOut = entity.DateOut.ToLocalTime(),
|
|
RoomCount = entity.RoomCount,
|
|
RoomNumber = entity.RoomNumber,
|
|
PaymentMethod = entity.PaymentMethod,
|
|
CreateTime = entity.CreateTime,
|
|
UpdateTime = entity.UpdateTime,
|
|
GuestDocuments = includeGuests ? [.. entity.GuestDocuments.Select(e => MapGuestDocumentEntityToDTO(e))] : null,
|
|
};
|
|
}
|
|
|
|
}
|