mirror of
https://github.com/jcreek/Creek.FileRepository.git
synced 2026-07-12 18:33:43 +00:00
refactor(*): Remove the id from RepoFile as the filename can be used instead as a UID
This commit is contained in:
@@ -14,28 +14,28 @@ namespace FileRepository
|
|||||||
/// Create a file in the repository.
|
/// Create a file in the repository.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="file">The file to store.</param>
|
/// <param name="file">The file to store.</param>
|
||||||
/// <returns>Returns a string id of the created file.</returns>
|
/// <returns>Returns a string fileName of the created file.</returns>
|
||||||
Task<string> CreateFileAsync(RepoFile file);
|
Task<string> CreateFileAsync(RepoFile file);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Read a file from the repository.
|
/// Read a file from the repository.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id">The id of the file to read.</param>
|
/// <param name="fileName">The file name of the file to read.</param>
|
||||||
/// <returns>Returns the file from the repository.</returns>
|
/// <returns>Returns the file from the repository.</returns>
|
||||||
Task<RepoFile> ReadFileAsync(string id);
|
Task<RepoFile> ReadFileAsync(string fileName);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Update a file in the repository.
|
/// Update a file in the repository.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id">The id of the file to update.</param>
|
/// <param name="fileName">The file name of the file to update.</param>
|
||||||
/// <returns>Returns a boolean representing whether or not the update was successful.</returns>
|
/// <returns>Returns a boolean representing whether or not the update was successful.</returns>
|
||||||
Task<bool> UpdateFileAsync(string id);
|
Task<bool> UpdateFileAsync(string fileName);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Delete a file in the repository.
|
/// Delete a file in the repository.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id">The id of the file to delete.</param>
|
/// <param name="fileName">The file name of the file to delete.</param>
|
||||||
/// <returns>Returns a boolean representing whether or not the delete was successful.</returns>
|
/// <returns>Returns a boolean representing whether or not the delete was successful.</returns>
|
||||||
Task<bool> DeleteFileAsync(string id);
|
Task<bool> DeleteFileAsync(string fileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,12 +9,7 @@ namespace FileRepository.Models
|
|||||||
public class RepoFile
|
public class RepoFile
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the id field for the file, this serves as the key field/unique identifier.
|
/// Gets or sets the actual file name of the file, this serves as the key field/unique identifier.
|
||||||
/// </summary>
|
|
||||||
public string Id { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the actual file name of the file.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string FileName { get; set; }
|
public string FileName { get; set; }
|
||||||
|
|
||||||
@@ -31,15 +26,13 @@ namespace FileRepository.Models
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initialise a File model based on passed parameters.
|
/// Initialise a File model based on passed parameters.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id">The id of the file.</param>
|
|
||||||
/// <param name="fileName">The filename of the file.</param>
|
/// <param name="fileName">The filename of the file.</param>
|
||||||
/// <param name="content">The content of the file.</param>
|
/// <param name="content">The content of the file.</param>
|
||||||
/// <returns>Returns an initialised File object.</returns>
|
/// <returns>Returns an initialised File object.</returns>
|
||||||
public RepoFile GenerateFile(string id, string fileName, Stream content)
|
public RepoFile GenerateFile(string fileName, Stream content)
|
||||||
{
|
{
|
||||||
RepoFile newFile = new RepoFile()
|
RepoFile newFile = new RepoFile()
|
||||||
{
|
{
|
||||||
Id = id,
|
|
||||||
FileName = fileName,
|
FileName = fileName,
|
||||||
Content = content,
|
Content = content,
|
||||||
Created = DateTime.Now,
|
Created = DateTime.Now,
|
||||||
|
|||||||
Reference in New Issue
Block a user