public ActionResult AddPage(PageViewModel model) { if (!ModelState.IsValid) { return(this.View(model)); } var result = _pagesService.Get(model.Id); if (result != null) { var seoEquals = _seoService.Get(model.Id)?.Name.Equals(model.SeoUrl); var seoUrl = new BllSeo { Id = model.Id, Name = model.SeoUrl }; if (seoEquals.HasValue && !seoEquals.Value) { _seoService.Update(new BllSeo { Id = model.Id, Name = model.SeoUrl }); } ViewBag.ReturnUrl = this.Url.RouteUrl("Default", new { action = "AddPage", controller = "Content", id = model.SeoUrl }); _pagesService.Update(model.ToBll(seoUrl)); return(this.View(model)); } if (_seoService.Get(model.SeoUrl) != null) { ModelState.AddModelError("SeoUrl", "Url is already defined"); return(this.View(model)); } ViewBag.ReturnUrl = this.Url.Action("AddPage", "Content"); var seo = _seoService.Create(new BllSeo { Name = model.SeoUrl }); _pagesService.Create(model.ToBll(seo)); return(this.View(model)); }
public IActionResult Post([FromBody] CreatePageDTO obj) { SubmitResult = _service.Create(obj); return(Respond()); }