Server naming fixes and cleanup
Server is now completely cleaned up and without warnings
This commit is contained in:
@ -3,10 +3,10 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Oqtane.Modules.HtmlText.Models;
|
||||
using Oqtane.Modules.HtmlText.Repository;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Oqtane.Infrastructure;
|
||||
using Oqtane.Shared;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Oqtane.Infrastructure.Interfaces;
|
||||
|
||||
namespace Oqtane.Modules.HtmlText.Controllers
|
||||
{
|
||||
@ -35,11 +35,11 @@ namespace Oqtane.Modules.HtmlText.Controllers
|
||||
var list = new List<HtmlTextInfo>();
|
||||
try
|
||||
{
|
||||
HtmlTextInfo HtmlText = null;
|
||||
HtmlTextInfo htmlText = null;
|
||||
if (_entityId == id)
|
||||
{
|
||||
HtmlText = _htmlText.GetHtmlText(id);
|
||||
list.Add(HtmlText);
|
||||
htmlText = _htmlText.GetHtmlText(id);
|
||||
list.Add(htmlText);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -53,16 +53,16 @@ namespace Oqtane.Modules.HtmlText.Controllers
|
||||
// POST api/<controller>
|
||||
[HttpPost]
|
||||
[Authorize(Policy = "EditModule")]
|
||||
public HtmlTextInfo Post([FromBody] HtmlTextInfo HtmlText)
|
||||
public HtmlTextInfo Post([FromBody] HtmlTextInfo htmlText)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (ModelState.IsValid && HtmlText.ModuleId == _entityId)
|
||||
if (ModelState.IsValid && htmlText.ModuleId == _entityId)
|
||||
{
|
||||
HtmlText = _htmlText.AddHtmlText(HtmlText);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Html/Text Added {HtmlText}", HtmlText);
|
||||
htmlText = _htmlText.AddHtmlText(htmlText);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Html/Text Added {HtmlText}", htmlText);
|
||||
}
|
||||
return HtmlText;
|
||||
return htmlText;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -74,16 +74,16 @@ namespace Oqtane.Modules.HtmlText.Controllers
|
||||
// PUT api/<controller>/5
|
||||
[HttpPut("{id}")]
|
||||
[Authorize(Policy = "EditModule")]
|
||||
public HtmlTextInfo Put(int id, [FromBody] HtmlTextInfo HtmlText)
|
||||
public HtmlTextInfo Put(int id, [FromBody] HtmlTextInfo htmlText)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (ModelState.IsValid && HtmlText.ModuleId == _entityId)
|
||||
if (ModelState.IsValid && htmlText.ModuleId == _entityId)
|
||||
{
|
||||
HtmlText = _htmlText.UpdateHtmlText(HtmlText);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Html/Text Updated {HtmlText}", HtmlText);
|
||||
htmlText = _htmlText.UpdateHtmlText(htmlText);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Html/Text Updated {HtmlText}", htmlText);
|
||||
}
|
||||
return HtmlText;
|
||||
return htmlText;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -14,10 +14,10 @@ namespace Oqtane.Modules.HtmlText.Manager
|
||||
_htmlTexts = htmltexts;
|
||||
}
|
||||
|
||||
public string ExportModule(Module Module)
|
||||
public string ExportModule(Module module)
|
||||
{
|
||||
string content = "";
|
||||
HtmlTextInfo htmltext = _htmlTexts.GetHtmlText(Module.ModuleId);
|
||||
HtmlTextInfo htmltext = _htmlTexts.GetHtmlText(module.ModuleId);
|
||||
if (htmltext != null)
|
||||
{
|
||||
content = WebUtility.HtmlEncode(htmltext.Content);
|
||||
@ -25,20 +25,20 @@ namespace Oqtane.Modules.HtmlText.Manager
|
||||
return content;
|
||||
}
|
||||
|
||||
public void ImportModule(Module Module, string Content, string Version)
|
||||
public void ImportModule(Module module, string content, string version)
|
||||
{
|
||||
Content = WebUtility.HtmlDecode(Content);
|
||||
HtmlTextInfo htmltext = _htmlTexts.GetHtmlText(Module.ModuleId);
|
||||
content = WebUtility.HtmlDecode(content);
|
||||
HtmlTextInfo htmltext = _htmlTexts.GetHtmlText(module.ModuleId);
|
||||
if (htmltext != null)
|
||||
{
|
||||
htmltext.Content = Content;
|
||||
htmltext.Content = content;
|
||||
_htmlTexts.UpdateHtmlText(htmltext);
|
||||
}
|
||||
else
|
||||
{
|
||||
htmltext = new HtmlTextInfo();
|
||||
htmltext.ModuleId = Module.ModuleId;
|
||||
htmltext.Content = Content;
|
||||
htmltext.ModuleId = module.ModuleId;
|
||||
htmltext.Content = content;
|
||||
_htmlTexts.AddHtmlText(htmltext);
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ namespace Oqtane.Modules.HtmlText.Repository
|
||||
{
|
||||
public virtual DbSet<HtmlTextInfo> HtmlText { get; set; }
|
||||
|
||||
public HtmlTextContext(ITenantResolver TenantResolver, IHttpContextAccessor accessor) : base(TenantResolver, accessor)
|
||||
public HtmlTextContext(ITenantResolver tenantResolver, IHttpContextAccessor accessor) : base(tenantResolver, accessor)
|
||||
{
|
||||
// ContextBase handles multi-tenant database connections
|
||||
}
|
||||
|
@ -13,59 +13,31 @@ namespace Oqtane.Modules.HtmlText.Repository
|
||||
_db = context;
|
||||
}
|
||||
|
||||
public HtmlTextInfo GetHtmlText(int ModuleId)
|
||||
public HtmlTextInfo GetHtmlText(int moduleId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _db.HtmlText.Where(item => item.ModuleId == ModuleId).FirstOrDefault();
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
return _db.HtmlText.FirstOrDefault(item => item.ModuleId == moduleId);
|
||||
}
|
||||
|
||||
|
||||
public HtmlTextInfo AddHtmlText(HtmlTextInfo HtmlText)
|
||||
public HtmlTextInfo AddHtmlText(HtmlTextInfo htmlText)
|
||||
{
|
||||
try
|
||||
{
|
||||
_db.HtmlText.Add(HtmlText);
|
||||
_db.SaveChanges();
|
||||
return HtmlText;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
_db.HtmlText.Add(htmlText);
|
||||
_db.SaveChanges();
|
||||
return htmlText;
|
||||
}
|
||||
|
||||
public HtmlTextInfo UpdateHtmlText(HtmlTextInfo HtmlText)
|
||||
public HtmlTextInfo UpdateHtmlText(HtmlTextInfo htmlText)
|
||||
{
|
||||
try
|
||||
{
|
||||
_db.Entry(HtmlText).State = EntityState.Modified;
|
||||
_db.SaveChanges();
|
||||
return HtmlText;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
_db.Entry(htmlText).State = EntityState.Modified;
|
||||
_db.SaveChanges();
|
||||
return htmlText;
|
||||
}
|
||||
|
||||
public void DeleteHtmlText(int ModuleId)
|
||||
public void DeleteHtmlText(int moduleId)
|
||||
{
|
||||
try
|
||||
{
|
||||
HtmlTextInfo HtmlText = _db.HtmlText.Where(item => item.ModuleId == ModuleId).FirstOrDefault();
|
||||
_db.HtmlText.Remove(HtmlText);
|
||||
_db.SaveChanges();
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
HtmlTextInfo htmlText = _db.HtmlText.FirstOrDefault(item => item.ModuleId == moduleId);
|
||||
if (htmlText != null) _db.HtmlText.Remove(htmlText);
|
||||
_db.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,12 @@
|
||||
using System.Collections.Generic;
|
||||
using Oqtane.Modules.HtmlText.Models;
|
||||
using Oqtane.Modules.HtmlText.Models;
|
||||
|
||||
namespace Oqtane.Modules.HtmlText.Repository
|
||||
{
|
||||
public interface IHtmlTextRepository
|
||||
{
|
||||
HtmlTextInfo GetHtmlText(int ModuleId);
|
||||
HtmlTextInfo AddHtmlText(HtmlTextInfo HtmlText);
|
||||
HtmlTextInfo UpdateHtmlText(HtmlTextInfo HtmlText);
|
||||
void DeleteHtmlText(int ModuleId);
|
||||
HtmlTextInfo GetHtmlText(int moduleId);
|
||||
HtmlTextInfo AddHtmlText(HtmlTextInfo htmlText);
|
||||
HtmlTextInfo UpdateHtmlText(HtmlTextInfo htmlText);
|
||||
void DeleteHtmlText(int moduleId);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user