public async Task UpdateHtmlTextAsync(Models.HtmlText htmlText) { await PutJsonAsync(CreateAuthorizationPolicyUrl($"{ApiUrl}/{htmlText.HtmlTextId}", new Dictionary <string, int>() { { EntityNames.Module, htmlText.ModuleId } }), htmlText); }
public void DeleteHtmlText(int htmlTextId) { Models.HtmlText htmlText = _db.HtmlText.FirstOrDefault(item => item.HtmlTextId == htmlTextId); if (htmlText != null) { _db.HtmlText.Remove(htmlText); } _db.SaveChanges(); }
public void ImportModule(Module module, string content, string version) { content = WebUtility.HtmlDecode(content); var htmlText = new Models.HtmlText(); htmlText.ModuleId = module.ModuleId; htmlText.Content = content; _htmlText.AddHtmlText(htmlText); }
public Models.HtmlText Put(int id, [FromBody] Models.HtmlText htmlText) { if (ModelState.IsValid && AuthEntityId(EntityNames.Module) == htmlText.ModuleId) { htmlText = _htmlText.UpdateHtmlText(htmlText); _logger.Log(LogLevel.Information, this, LogFunction.Update, "Html/Text Updated {HtmlText}", htmlText); return(htmlText); } else { _logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized HtmlText Put Attempt {HtmlText}", htmlText); HttpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden; return(null); } }
public Models.HtmlText Put(int id, [FromBody] Models.HtmlText htmlText) { try { if (ModelState.IsValid && htmlText.ModuleId == _authEntityId[EntityNames.Module]) { 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); throw; } }
public void ImportModule(Module module, string content, string version) { content = WebUtility.HtmlDecode(content); var htmlText = _htmlText.GetHtmlText(module.ModuleId); if (htmlText != null) { htmlText.Content = content; _htmlText.UpdateHtmlText(htmlText); } else { htmlText = new Models.HtmlText(); htmlText.ModuleId = module.ModuleId; htmlText.Content = content; _htmlText.AddHtmlText(htmlText); } }
public List <Models.HtmlText> Get(int id) { var list = new List <Models.HtmlText>(); try { Models.HtmlText htmlText = null; if (_authEntityId[EntityNames.Module] == id) { htmlText = _htmlText.GetHtmlText(id); list.Add(htmlText); } } catch (Exception ex) { _logger.Log(LogLevel.Error, this, LogFunction.Read, ex, "Get Error {Error}", ex.Message); throw; } return(list); }
public Models.HtmlText AddHtmlText(Models.HtmlText htmlText) { _db.HtmlText.Add(htmlText); _db.SaveChanges(); return(htmlText); }
public async Task AddHtmlTextAsync(Models.HtmlText htmlText) { await PostJsonAsync(CreateAuthorizationPolicyUrl($"{ApiUrl}", EntityNames.Module, htmlText.ModuleId), htmlText); }
public async Task UpdateHtmlTextAsync(Models.HtmlText htmlText) { await PutJsonAsync(CreateAuthorizationPolicyUrl($"{ApiUrl}/{htmlText.HtmlTextId}", EntityNames.Module, htmlText.ModuleId), htmlText); }
public Models.HtmlText UpdateHtmlText(Models.HtmlText htmlText) { _db.Entry(htmlText).State = EntityState.Modified; _db.SaveChanges(); return(htmlText); }