SHA256
feat StayExport - Initial Implementation
- Created models for DB and DTOs: StayExportFile - Added required db migrations. - Added StayExportService and StayExportServiceFactory for stay exporting services. - Added configuration options required for StayExport.
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
namespace Somnia.GuestLog.Models.Configuration;
|
||||
|
||||
public class StayExportConfig
|
||||
{
|
||||
public const string SectionName = "StayExport";
|
||||
|
||||
public bool EnableStayExport { get; set; } = false;
|
||||
public string? ExportStorageConnectionString { get; set; }
|
||||
public bool UseSubdirectoryByFormat { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using Somnia.GuestLog.Enums.Models;
|
||||
|
||||
namespace Somnia.GuestLog.Models.DTOs;
|
||||
|
||||
public class StayExportFileDTO
|
||||
{
|
||||
public long? Id { get; set; }
|
||||
|
||||
public StayExportFormat? ExportFormat { get; set; }
|
||||
|
||||
public StayExportParamsDTO? ExportParams { get; set; }
|
||||
|
||||
public StayExportFileResult? ExportResult { get; set; }
|
||||
|
||||
public string? ExportedPath { get; set; }
|
||||
|
||||
|
||||
public DateTime? ExportTime { get; set; }
|
||||
}
|
||||
|
||||
public class StayExportParamsDTO
|
||||
{
|
||||
public StayExportParamType? ExportType { get; set; }
|
||||
|
||||
public DateTime? ExportPeriodStart { get; set; }
|
||||
public DateTime? ExportPeriodEnd { get; set; }
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
using Somnia.GuestLog.Infrastructure;
|
||||
|
||||
namespace Somnia.GuestLog.Models.Entities;
|
||||
|
||||
public class GuestAddress : BaseEntity
|
||||
@@ -9,5 +11,5 @@ public class GuestAddress : BaseEntity
|
||||
public required string AddressCountry { get; set; }
|
||||
public string? ZipCode { get; set; }
|
||||
|
||||
public override string GetFullKey() => "N/A";
|
||||
public override string GetFullKey() => DbConsts.PK_NotApply;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using Somnia.GuestLog.Enums.Models;
|
||||
|
||||
namespace Somnia.GuestLog.Models.Entities;
|
||||
|
||||
public class StayExportFile : BaseEntity
|
||||
{
|
||||
public long Id { get; set; }
|
||||
|
||||
public required StayExportFormat ExportFormat { get; set; }
|
||||
public required StayExportParams ExportParams { get; set; }
|
||||
|
||||
public required StayExportFileResult ExportResult { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Path to exported data.
|
||||
/// Should be relative to configured Storage.
|
||||
/// </summary>
|
||||
public string? ExportedPath { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Date/Time when export file was generated.
|
||||
/// </summary>
|
||||
public required DateTime ExportTime { get; set; }
|
||||
|
||||
|
||||
public override string GetFullKey() => $"{Id}";
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using Somnia.GuestLog.Enums.Models;
|
||||
using Somnia.GuestLog.Infrastructure;
|
||||
|
||||
namespace Somnia.GuestLog.Models.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// This class store params used on StayExport.
|
||||
/// Different params apply for different export types.
|
||||
/// </summary>
|
||||
public class StayExportParams : BaseEntity
|
||||
{
|
||||
public required StayExportParamType ExportType { get; set; }
|
||||
|
||||
public DateTime? ExportPeriodStart { get; set; }
|
||||
public DateTime? ExportPeriodEnd { get; set; }
|
||||
|
||||
|
||||
public override string GetFullKey() => DbConsts.PK_NotApply;
|
||||
}
|
||||
@@ -51,4 +51,24 @@ internal static class EntityMapping
|
||||
};
|
||||
}
|
||||
|
||||
public static StayExportFileDTO MapStayExportFileEntityToDTO(StayExportFile entity)
|
||||
{
|
||||
StayExportParamsDTO exportParamsDto = new()
|
||||
{
|
||||
ExportType = entity.ExportParams.ExportType,
|
||||
ExportPeriodStart = entity.ExportParams.ExportPeriodStart,
|
||||
ExportPeriodEnd = entity.ExportParams.ExportPeriodEnd,
|
||||
};
|
||||
|
||||
return new()
|
||||
{
|
||||
Id = entity.Id,
|
||||
ExportFormat = entity.ExportFormat,
|
||||
ExportParams = exportParamsDto,
|
||||
ExportResult = entity.ExportResult,
|
||||
ExportedPath = entity.ExportedPath,
|
||||
ExportTime = entity.ExportTime,
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user