Class FileRepository
Implements
Inherited Members
Namespace: OEMS.Core.Infrastructure.Repositories
Assembly: OEMS.Core.dll
Syntax
public class FileRepository : IFileRepository
Constructors
FileRepository(IDbContextFactory<OEMSDBContext>)
Declaration
public FileRepository(IDbContextFactory<OEMSDBContext> contextFactory)
Parameters
Type | Name | Description |
---|---|---|
IDbContextFactory<OEMSDBContext> | contextFactory |
Methods
AddAsync(File)
Adds a new file entity to the repository.
Declaration
public Task<File> AddAsync(File file)
Parameters
Type | Name | Description |
---|---|---|
File | file | The file entity to add |
Returns
Type | Description |
---|---|
Task<File> | The added file entity with updated properties |
DeleteFileAsync(Guid)
Deletes a file by its identifier.
Declaration
public Task DeleteFileAsync(Guid id)
Parameters
Type | Name | Description |
---|---|---|
Guid | id |
Returns
Type | Description |
---|---|
Task | A task representing the asynchronous operation |
GetFileById(Guid)
Retrieves a file entity by its identifier.
Declaration
public Task<File> GetFileById(Guid id)
Parameters
Type | Name | Description |
---|---|---|
Guid | id |
Returns
Type | Description |
---|---|
Task<File> | The file entity, or null if not found |
GetFilePathById(Guid)
Retrieves the file path for a file by its identifier.
Declaration
public Task<string> GetFilePathById(Guid fileId)
Parameters
Type | Name | Description |
---|---|---|
Guid | fileId | The unique identifier of the file |
Returns
Type | Description |
---|---|
Task<string> | The file path, or null if not found |
GetFilePathByName(string)
Retrieves the file path for a file by its name.
Declaration
public Task<string> GetFilePathByName(string fileName)
Parameters
Type | Name | Description |
---|---|---|
string | fileName | The name of the file |
Returns
Type | Description |
---|---|
Task<string> | The file path, or null if not found |
GetFilesByIdsAsync(IEnumerable<Guid>)
Retrieves multiple files by their identifiers.
Declaration
public Task<Dictionary<Guid, File>> GetFilesByIdsAsync(IEnumerable<Guid> fileIds)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<Guid> | fileIds | The collection of file identifiers |
Returns
Type | Description |
---|---|
Task<Dictionary<Guid, File>> | A dictionary mapping file IDs to file entities |
GetLogoUrl(Guid)
Retrieves the URL for accessing a logo file.
Declaration
public Task<string> GetLogoUrl(Guid fileId)
Parameters
Type | Name | Description |
---|---|---|
Guid | fileId | The unique identifier of the logo file |
Returns
Type | Description |
---|---|
Task<string> | The URL for accessing the logo |
SaveFileAsync(string, string)
Saves a file with the specified path and name.
Declaration
public Task<Guid> SaveFileAsync(string filePath, string fileName)
Parameters
Type | Name | Description |
---|---|---|
string | filePath | The path where the file is stored |
string | fileName | The name of the file |
Returns
Type | Description |
---|---|
Task<Guid> | The unique identifier of the saved file |