Fix naming conventions for private fields

This commit is contained in:
Hisham Bin Ateya
2020-03-05 01:46:53 +03:00
parent e74f0d7644
commit a46235ea1e
75 changed files with 1219 additions and 1219 deletions

View File

@ -12,17 +12,17 @@ namespace Oqtane.Modules.HtmlText.Controllers
[Route("{site}/api/[controller]")]
public class HtmlTextController : Controller
{
private readonly IHtmlTextRepository htmltext;
private readonly ILogManager logger;
private int EntityId = -1; // passed as a querystring parameter for authorization and used for validation
private readonly IHtmlTextRepository _htmlText;
private readonly ILogManager _logger;
private int _entityId = -1; // passed as a querystring parameter for authorization and used for validation
public HtmlTextController(IHtmlTextRepository HtmlText, ILogManager logger, IHttpContextAccessor HttpContextAccessor)
{
htmltext = HtmlText;
this.logger = logger;
_htmlText = HtmlText;
this._logger = logger;
if (HttpContextAccessor.HttpContext.Request.Query.ContainsKey("entityid"))
{
EntityId = int.Parse(HttpContextAccessor.HttpContext.Request.Query["entityid"]);
_entityId = int.Parse(HttpContextAccessor.HttpContext.Request.Query["entityid"]);
}
}
@ -34,15 +34,15 @@ namespace Oqtane.Modules.HtmlText.Controllers
try
{
HtmlTextInfo HtmlText = null;
if (EntityId == id)
if (_entityId == id)
{
HtmlText = htmltext.GetHtmlText(id);
HtmlText = _htmlText.GetHtmlText(id);
}
return HtmlText;
}
catch (Exception ex)
{
logger.Log(LogLevel.Error, this, LogFunction.Read, ex, "Get Error {Error}", ex.Message);
_logger.Log(LogLevel.Error, this, LogFunction.Read, ex, "Get Error {Error}", ex.Message);
throw;
}
}
@ -54,16 +54,16 @@ namespace Oqtane.Modules.HtmlText.Controllers
{
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;
}
catch (Exception ex)
{
logger.Log(LogLevel.Error, this, LogFunction.Create, ex, "Post Error {Error}", ex.Message);
_logger.Log(LogLevel.Error, this, LogFunction.Create, ex, "Post Error {Error}", ex.Message);
throw;
}
}
@ -75,16 +75,16 @@ namespace Oqtane.Modules.HtmlText.Controllers
{
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;
}
catch (Exception ex)
{
logger.Log(LogLevel.Error, this, LogFunction.Update, ex, "Put Error {Error}", ex.Message);
_logger.Log(LogLevel.Error, this, LogFunction.Update, ex, "Put Error {Error}", ex.Message);
throw;
}
}
@ -96,15 +96,15 @@ namespace Oqtane.Modules.HtmlText.Controllers
{
try
{
if (id == EntityId)
if (id == _entityId)
{
htmltext.DeleteHtmlText(id);
logger.Log(LogLevel.Information, this, LogFunction.Delete, "Html/Text Deleted {HtmlTextId}", id);
_htmlText.DeleteHtmlText(id);
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "Html/Text Deleted {HtmlTextId}", id);
}
}
catch (Exception ex)
{
logger.Log(LogLevel.Error, this, LogFunction.Delete, ex, "Delete Error {Error}", ex.Message);
_logger.Log(LogLevel.Error, this, LogFunction.Delete, ex, "Delete Error {Error}", ex.Message);
throw;
}
}

View File

@ -7,17 +7,17 @@ namespace Oqtane.Modules.HtmlText.Manager
{
public class HtmlTextManager : IPortable
{
private IHtmlTextRepository htmltexts;
private IHtmlTextRepository _htmlTexts;
public HtmlTextManager(IHtmlTextRepository htmltexts)
{
this.htmltexts = htmltexts;
this._htmlTexts = htmltexts;
}
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);
@ -28,18 +28,18 @@ namespace Oqtane.Modules.HtmlText.Manager
public void ImportModule(Module Module, string Content, string Version)
{
Content = WebUtility.HtmlDecode(Content);
HtmlTextInfo htmltext = htmltexts.GetHtmlText(Module.ModuleId);
HtmlTextInfo htmltext = _htmlTexts.GetHtmlText(Module.ModuleId);
if (htmltext != null)
{
htmltext.Content = Content;
htmltexts.UpdateHtmlText(htmltext);
_htmlTexts.UpdateHtmlText(htmltext);
}
else
{
htmltext = new HtmlTextInfo();
htmltext.ModuleId = Module.ModuleId;
htmltext.Content = Content;
htmltexts.AddHtmlText(htmltext);
_htmlTexts.AddHtmlText(htmltext);
}
}
}

View File

@ -6,18 +6,18 @@ namespace Oqtane.Modules.HtmlText.Repository
{
public class HtmlTextRepository : IHtmlTextRepository, IService
{
private readonly HtmlTextContext db;
private readonly HtmlTextContext _db;
public HtmlTextRepository(HtmlTextContext context)
{
db = context;
_db = context;
}
public HtmlTextInfo GetHtmlText(int ModuleId)
{
try
{
return db.HtmlText.Where(item => item.ModuleId == ModuleId).FirstOrDefault();
return _db.HtmlText.Where(item => item.ModuleId == ModuleId).FirstOrDefault();
}
catch
{
@ -30,8 +30,8 @@ namespace Oqtane.Modules.HtmlText.Repository
{
try
{
db.HtmlText.Add(HtmlText);
db.SaveChanges();
_db.HtmlText.Add(HtmlText);
_db.SaveChanges();
return HtmlText;
}
catch
@ -44,8 +44,8 @@ namespace Oqtane.Modules.HtmlText.Repository
{
try
{
db.Entry(HtmlText).State = EntityState.Modified;
db.SaveChanges();
_db.Entry(HtmlText).State = EntityState.Modified;
_db.SaveChanges();
return HtmlText;
}
catch
@ -58,9 +58,9 @@ namespace Oqtane.Modules.HtmlText.Repository
{
try
{
HtmlTextInfo HtmlText = db.HtmlText.Where(item => item.ModuleId == ModuleId).FirstOrDefault();
db.HtmlText.Remove(HtmlText);
db.SaveChanges();
HtmlTextInfo HtmlText = _db.HtmlText.Where(item => item.ModuleId == ModuleId).FirstOrDefault();
_db.HtmlText.Remove(HtmlText);
_db.SaveChanges();
}
catch
{