Initial
This commit is contained in:
27
MareSynchronos/WebAPI/Files/Models/FileTransfer.cs
Normal file
27
MareSynchronos/WebAPI/Files/Models/FileTransfer.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using MareSynchronos.API.Dto.Files;
|
||||
|
||||
namespace MareSynchronos.WebAPI.Files.Models;
|
||||
|
||||
public abstract class FileTransfer
|
||||
{
|
||||
protected readonly ITransferFileDto TransferDto;
|
||||
|
||||
protected FileTransfer(ITransferFileDto transferDto)
|
||||
{
|
||||
TransferDto = transferDto;
|
||||
}
|
||||
|
||||
public virtual bool CanBeTransferred => !TransferDto.IsForbidden && (TransferDto is not DownloadFileDto dto || dto.FileExists);
|
||||
public string ForbiddenBy => TransferDto.ForbiddenBy;
|
||||
public string Hash => TransferDto.Hash;
|
||||
public bool IsForbidden => TransferDto.IsForbidden;
|
||||
public bool IsInTransfer => Transferred != Total && Transferred > 0;
|
||||
public bool IsTransferred => Transferred == Total;
|
||||
public abstract long Total { get; set; }
|
||||
public long Transferred { get; set; } = 0;
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Hash;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user