introducing Site Groups
This commit is contained in:
@@ -2,17 +2,29 @@ using System.Linq;
|
||||
using Oqtane.Documentation;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Oqtane.Repository;
|
||||
|
||||
namespace Oqtane.Modules.HtmlText.Repository
|
||||
{
|
||||
[PrivateApi("Mark HtmlText classes as private, since it's not very useful in the public docs")]
|
||||
public interface IHtmlTextRepository
|
||||
{
|
||||
IEnumerable<Models.HtmlText> GetHtmlTexts(int moduleId);
|
||||
Models.HtmlText GetHtmlText(int htmlTextId);
|
||||
Models.HtmlText AddHtmlText(Models.HtmlText htmlText);
|
||||
void DeleteHtmlText(int htmlTextId);
|
||||
}
|
||||
|
||||
[PrivateApi("Mark HtmlText classes as private, since it's not very useful in the public docs")]
|
||||
public class HtmlTextRepository : IHtmlTextRepository, ITransientService
|
||||
{
|
||||
private readonly IDbContextFactory<HtmlTextContext> _factory;
|
||||
private readonly IModuleRepository _moduleRepository;
|
||||
|
||||
public HtmlTextRepository(IDbContextFactory<HtmlTextContext> factory)
|
||||
public HtmlTextRepository(IDbContextFactory<HtmlTextContext> factory, IModuleRepository moduleRepository)
|
||||
{
|
||||
_factory = factory;
|
||||
_moduleRepository = moduleRepository;
|
||||
}
|
||||
|
||||
public IEnumerable<Models.HtmlText> GetHtmlTexts(int moduleId)
|
||||
@@ -32,6 +44,11 @@ namespace Oqtane.Modules.HtmlText.Repository
|
||||
using var db = _factory.CreateDbContext();
|
||||
db.HtmlText.Add(htmlText);
|
||||
db.SaveChanges();
|
||||
|
||||
// update module ModifiedOn date
|
||||
var module = _moduleRepository.GetModule(htmlText.ModuleId);
|
||||
_moduleRepository.UpdateModule(module);
|
||||
|
||||
return htmlText;
|
||||
}
|
||||
|
||||
@@ -39,8 +56,15 @@ namespace Oqtane.Modules.HtmlText.Repository
|
||||
{
|
||||
using var db = _factory.CreateDbContext();
|
||||
Models.HtmlText htmlText = db.HtmlText.FirstOrDefault(item => item.HtmlTextId == htmlTextId);
|
||||
if (htmlText != null) db.HtmlText.Remove(htmlText);
|
||||
db.SaveChanges();
|
||||
if (htmlText != null)
|
||||
{
|
||||
db.HtmlText.Remove(htmlText);
|
||||
db.SaveChanges();
|
||||
|
||||
// update module ModifiedOn date
|
||||
var module = _moduleRepository.GetModule(htmlText.ModuleId);
|
||||
_moduleRepository.UpdateModule(module);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using Oqtane.Documentation;
|
||||
|
||||
namespace Oqtane.Modules.HtmlText.Repository
|
||||
{
|
||||
[PrivateApi("Mark HtmlText classes as private, since it's not very useful in the public docs")]
|
||||
public interface IHtmlTextRepository
|
||||
{
|
||||
IEnumerable<Models.HtmlText> GetHtmlTexts(int moduleId);
|
||||
Models.HtmlText GetHtmlText(int htmlTextId);
|
||||
Models.HtmlText AddHtmlText(Models.HtmlText htmlText);
|
||||
void DeleteHtmlText(int htmlTextId);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user