78 lines
2.1 KiB
C#
78 lines
2.1 KiB
C#
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
using LCU.Library.Internal.ApiResponse.Models;
|
|
using LCU.Library.Internal.FileOperationsModels.Models.NameSettings;
|
|
using LCU.Library.Internal.FileOperationsModels.Shared;
|
|
|
|
namespace LCU.Library.Internal.FileOperationsModels.Models
|
|
{
|
|
public class ModifyFileRequest : ReturnResponse
|
|
{
|
|
[Required(ErrorMessage = "Source path is required")]
|
|
public string SourcePath { get; set; }
|
|
[Required(ErrorMessage = "Source file is required")]
|
|
public string SourceFile { get; set; }
|
|
public string PrependText { get; set; }
|
|
public string SourceExtension { get; set; }
|
|
public string AppendText { get; set; }
|
|
public string NewExtension { get; set; }
|
|
public int MaxAmountOfFiles { get; set; } = 0;
|
|
public bool SucceedOnError { get; set; }
|
|
public DynamicNameSetting FileNameSetting { get; set; }
|
|
[NotMapped]
|
|
public string OriginalSource
|
|
{
|
|
get
|
|
{
|
|
var finalSourcePath = SourcePath.EndsWith("\\") ? SourcePath : $"{SourcePath}\\";
|
|
return finalSourcePath + OriginalSourceFile;
|
|
}
|
|
}
|
|
[NotMapped]
|
|
public string OriginalSourceFile
|
|
{
|
|
get
|
|
{
|
|
var fileName = DynamicNameBuilder.BuildDynamicName($"{SourceFile}.{SourceExtension}", FileNameSetting);
|
|
return fileName;
|
|
}
|
|
}
|
|
[NotMapped]
|
|
public string FinalSourceFile
|
|
{
|
|
get
|
|
{
|
|
var fileName = DynamicNameBuilder.BuildDynamicName(SourceFile, FileNameSetting);
|
|
var finalFileName = $"{PrependText}{fileName}{AppendText}.{FinalExtension}";
|
|
return finalFileName;
|
|
}
|
|
}
|
|
[NotMapped]
|
|
public string FinalSource
|
|
{
|
|
get
|
|
{
|
|
var finalSourcePath = SourcePath.EndsWith("\\") ? SourcePath : $"{SourcePath}\\";
|
|
return finalSourcePath + FinalSourceFile;
|
|
}
|
|
}
|
|
public static string GetNameWithoutExtension(string name, string extension)
|
|
{
|
|
var fileNameWithOutExtension = name.Replace("." + extension, string.Empty);
|
|
return fileNameWithOutExtension;
|
|
}
|
|
[NotMapped]
|
|
public string FinalExtension
|
|
{
|
|
get
|
|
{
|
|
if (string.IsNullOrWhiteSpace(NewExtension))
|
|
{
|
|
return SourceExtension;
|
|
}
|
|
|
|
return NewExtension;
|
|
}
|
|
}
|
|
}
|
|
} |