54 lines
1.4 KiB
C#
54 lines
1.4 KiB
C#
using LCU.Library.Internal.ApiResponse.Models;
|
|
using LCU.Library.Internal.FileOperationsModels.Models.NameSettings;
|
|
using LCU.Library.Internal.FileOperationsModels.Shared;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
|
|
namespace LCU.Library.Internal.FileOperationsModels.Models
|
|
{
|
|
public class ZipDirectoryRequest : ReturnResponse
|
|
{
|
|
[Required(ErrorMessage = "Source path is required")]
|
|
public string SourceDirectory { get; set; }
|
|
|
|
public string DirectoryName { get; set; }
|
|
|
|
[Required(ErrorMessage = "Zip path is required.")]
|
|
public string ZipPath { get; set; }
|
|
|
|
public string ZipFileName { get; set; }
|
|
|
|
public DynamicNameSetting FileNameSetting { get; set; }
|
|
|
|
[NotMapped]
|
|
public string DynamicDirectoryName
|
|
{
|
|
get
|
|
{
|
|
return DynamicNameBuilder.BuildDynamicName(DirectoryName, FileNameSetting);
|
|
}
|
|
}
|
|
|
|
[NotMapped]
|
|
public string FormattedSourceDirectory
|
|
{
|
|
get
|
|
{
|
|
return SourceDirectory.EndsWith("\\") ? SourceDirectory : $"{SourceDirectory}\\";
|
|
}
|
|
}
|
|
|
|
[NotMapped]
|
|
public string ZipDestination
|
|
{
|
|
get
|
|
{
|
|
var finalDestinationPath = ZipPath.EndsWith("\\") ? ZipPath : $"{ZipPath}\\";
|
|
var finalZipName = !string.IsNullOrWhiteSpace(ZipFileName) ? ZipFileName : DirectoryName;
|
|
finalZipName = finalZipName.ToUpper().EndsWith(".ZIP") ? finalZipName : $"{finalZipName}.zip";
|
|
return finalDestinationPath + finalZipName;
|
|
}
|
|
}
|
|
}
|
|
}
|