Improve HtmlText module performance

This commit is contained in:
Shaun Walker
2019-08-16 09:49:26 -04:00
parent 9cda80f7e9
commit 0c57813bf8
9 changed files with 128 additions and 38 deletions

View File

@ -15,13 +15,6 @@ namespace Oqtane.Server.Modules.HtmlText.Controllers
htmltext = HtmlText;
}
// GET: api/<controller>
[HttpGet]
public IEnumerable<HtmlTextInfo> Get()
{
return htmltext.GetHtmlText();
}
// GET api/<controller>/5
[HttpGet("{id}")]
public HtmlTextInfo Get(int id)

View File

@ -15,11 +15,11 @@ namespace Oqtane.Server.Modules.HtmlText.Repository
db = context;
}
public IEnumerable<HtmlTextInfo> GetHtmlText()
public HtmlTextInfo GetHtmlText(int ModuleId)
{
try
{
return db.HtmlText.ToList();
return db.HtmlText.Where(item => item.ModuleId == ModuleId).FirstOrDefault();
}
catch
{
@ -27,6 +27,7 @@ namespace Oqtane.Server.Modules.HtmlText.Repository
}
}
public HtmlTextInfo AddHtmlText(HtmlTextInfo HtmlText)
{
try
@ -55,19 +56,6 @@ namespace Oqtane.Server.Modules.HtmlText.Repository
}
}
public HtmlTextInfo GetHtmlText(int HtmlTextId)
{
try
{
HtmlTextInfo HtmlText = db.HtmlText.Find(HtmlTextId);
return HtmlText;
}
catch
{
throw;
}
}
public void DeleteHtmlText(int HtmlTextId)
{
try

View File

@ -5,10 +5,9 @@ namespace Oqtane.Server.Modules.HtmlText.Repository
{
public interface IHtmlTextRepository
{
IEnumerable<HtmlTextInfo> GetHtmlText();
HtmlTextInfo GetHtmlText(int ModuleId);
HtmlTextInfo AddHtmlText(HtmlTextInfo HtmlText);
HtmlTextInfo UpdateHtmlText(HtmlTextInfo HtmlText);
HtmlTextInfo GetHtmlText(int HtmlTextIdId);
void DeleteHtmlText(int HtmlTextId);
}
}