Exemplo n.º 1
0
        public ActionResult Edit(int id = 0)
        {
            var record = _htmlBlockService.GetHtmlBlock(id);

            if (record == null)
            {
                record = new HtmlBlockRecord();
            }
            return(View(record));
        }
Exemplo n.º 2
0
 public void SaveHtmlBlock(HtmlBlockRecord record)
 {
     if (record.Id > 0)
     {
         _htmlBlockRepo.Update(record);
     }
     else
     {
         _htmlBlockRepo.Create(record);
     }
 }
Exemplo n.º 3
0
        public ActionResult Edit(HtmlBlockRecord record)
        {
            record.BlockKey = record.BlockKey.Trim();
            if (_htmlBlockService.BlockExists(record.BlockKey) && record.Id <= 0)
            {
                ModelState.AddModelError("BlockKey", "Html block with this key already exists");

                return(View(record));
            }
            _htmlBlockService.SaveHtmlBlock(record);
            return(RedirectToAction("List"));
        }
Exemplo n.º 4
0
        public void SetHtmlBlock(string blockKey, string html)
        {
            var block = _htmlBlockRepo
                        .Table
                        .FirstOrDefault(x => x.BlockKey == blockKey);

            if (block == null)
            {
                block          = new HtmlBlockRecord();
                block.BlockKey = blockKey;
                _htmlBlockRepo.Create(block);
            }
            block.HTML = html;
            _htmlBlockRepo.Update(block);
        }