Пример #1
0
        public ActionResult Edit()
        {
            TextContent textContent = _textContentsBL.Get(TextContentCode.RobotsTxt);

            RobotsTxtCreateOrEditViewModel model = new RobotsTxtCreateOrEditViewModel
            {
                Text = textContent == null ? string.Empty : textContent.Text,
                Id   = textContent == null ? (int?)null : textContent.Id
            };

            return(View(model));
        }
Пример #2
0
        public ActionResult Save(RobotsTxtCreateOrEditViewModel model)
        {
            if (ModelState.IsValid)
            {
                TextContent textContent;
                if (model.Id.HasValue)
                {
                    textContent = _textContentsBL.Get(TextContentCode.RobotsTxt);
                    AssignModelToEntity(model, textContent);
                    _textContentsBL.Update(textContent);
                }
                else
                {
                    textContent = new TextContent();
                    AssignModelToEntity(model, textContent);
                    _textContentsBL.Add(textContent);
                }
            }

            return(RedirectToAction("Edit", model));
        }
Пример #3
0
 private void AssignModelToEntity(RobotsTxtCreateOrEditViewModel model, TextContent entity)
 {
     entity.Code = TextContentCode.RobotsTxt;
     entity.Text = model.Text;
 }