Introduce GetFolderPath and GetFilePath repository methods
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Oqtane.Extensions;
|
||||
using Oqtane.Models;
|
||||
@ -11,11 +12,15 @@ namespace Oqtane.Repository
|
||||
{
|
||||
private TenantDBContext _db;
|
||||
private readonly IPermissionRepository _permissions;
|
||||
private readonly IWebHostEnvironment _environment;
|
||||
private readonly ITenantResolver _tenants;
|
||||
|
||||
public FolderRepository(TenantDBContext context, IPermissionRepository permissions)
|
||||
public FolderRepository(TenantDBContext context, IPermissionRepository permissions,IWebHostEnvironment environment, ITenantResolver tenants)
|
||||
{
|
||||
_db = context;
|
||||
_permissions = permissions;
|
||||
_environment = environment;
|
||||
_tenants = tenants;
|
||||
}
|
||||
|
||||
public IEnumerable<Folder> GetFolders(int siteId)
|
||||
@ -85,5 +90,17 @@ namespace Oqtane.Repository
|
||||
_db.Folder.Remove(folder);
|
||||
_db.SaveChanges();
|
||||
}
|
||||
|
||||
public string GetFolderPath(int folderId)
|
||||
{
|
||||
Folder folder = _db.Folder.Find(folderId);
|
||||
return GetFolderPath(folder);
|
||||
}
|
||||
|
||||
public string GetFolderPath(Folder folder)
|
||||
{
|
||||
return Utilities.PathCombine(_environment.ContentRootPath, "Content", "Tenants", _tenants.GetTenant().TenantId.ToString(), "Sites", folder.SiteId.ToString(), folder.Path);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user