Exemplo n.º 1
0
 public async Task UpdateHtmlTextAsync(Models.HtmlText htmlText)
 {
     await PutJsonAsync(CreateAuthorizationPolicyUrl($"{ApiUrl}/{htmlText.HtmlTextId}", new Dictionary <string, int>()
     {
         { EntityNames.Module, htmlText.ModuleId }
     }), htmlText);
 }
Exemplo n.º 2
0
 public void DeleteHtmlText(int htmlTextId)
 {
     Models.HtmlText htmlText = _db.HtmlText.FirstOrDefault(item => item.HtmlTextId == htmlTextId);
     if (htmlText != null)
     {
         _db.HtmlText.Remove(htmlText);
     }
     _db.SaveChanges();
 }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
 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);
     }
 }
Exemplo n.º 5
0
 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;
     }
 }
Exemplo n.º 6
0
        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);
            }
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
 public Models.HtmlText AddHtmlText(Models.HtmlText htmlText)
 {
     _db.HtmlText.Add(htmlText);
     _db.SaveChanges();
     return(htmlText);
 }
Exemplo n.º 9
0
 public async Task AddHtmlTextAsync(Models.HtmlText htmlText)
 {
     await PostJsonAsync(CreateAuthorizationPolicyUrl($"{ApiUrl}", EntityNames.Module, htmlText.ModuleId), htmlText);
 }
Exemplo n.º 10
0
 public async Task UpdateHtmlTextAsync(Models.HtmlText htmlText)
 {
     await PutJsonAsync(CreateAuthorizationPolicyUrl($"{ApiUrl}/{htmlText.HtmlTextId}", EntityNames.Module, htmlText.ModuleId), htmlText);
 }
Exemplo n.º 11
0
 public Models.HtmlText UpdateHtmlText(Models.HtmlText htmlText)
 {
     _db.Entry(htmlText).State = EntityState.Modified;
     _db.SaveChanges();
     return(htmlText);
 }