Introduce GetFolderPath and GetFilePath repository methods

This commit is contained in:
Pavel Vesely
2021-01-11 13:13:25 +01:00
parent a9a66155e2
commit f1a1a21d74
5 changed files with 48 additions and 14 deletions

View File

@ -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);
}
}
}