This repository has been archived on 2025-05-14. You can view files and clone it, but cannot push or open issues or pull requests.
Pavel Vesely 5b3feaf26f Server naming fixes and cleanup
Server is now completely cleaned up and without warnings
2020-03-15 11:53:24 +01:00

44 lines
1.2 KiB
C#

using Microsoft.EntityFrameworkCore;
using System.Linq;
using Oqtane.Modules.HtmlText.Models;
namespace Oqtane.Modules.HtmlText.Repository
{
public class HtmlTextRepository : IHtmlTextRepository, IService
{
private readonly HtmlTextContext _db;
public HtmlTextRepository(HtmlTextContext context)
{
_db = context;
}
public HtmlTextInfo GetHtmlText(int moduleId)
{
return _db.HtmlText.FirstOrDefault(item => item.ModuleId == moduleId);
}
public HtmlTextInfo AddHtmlText(HtmlTextInfo htmlText)
{
_db.HtmlText.Add(htmlText);
_db.SaveChanges();
return htmlText;
}
public HtmlTextInfo UpdateHtmlText(HtmlTextInfo htmlText)
{
_db.Entry(htmlText).State = EntityState.Modified;
_db.SaveChanges();
return htmlText;
}
public void DeleteHtmlText(int moduleId)
{
HtmlTextInfo htmlText = _db.HtmlText.FirstOrDefault(item => item.ModuleId == moduleId);
if (htmlText != null) _db.HtmlText.Remove(htmlText);
_db.SaveChanges();
}
}
}