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)); }
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)); }
private void AssignModelToEntity(RobotsTxtCreateOrEditViewModel model, TextContent entity) { entity.Code = TextContentCode.RobotsTxt; entity.Text = model.Text; }