public virtual async Task <ActionResult> EntitySlugEditor(int?ruleId, RedirectRuleGroup redirectGroup, int entityId) { RedirectModel model; if (ruleId != null) { var record = await _redirectsService.FindByIdAsync(ruleId.Value); model = _redirectModelFactory.PrepareRedirectModel(record); } else { model = _redirectModelFactory.PrepareRedirectModel(null); model.MatchType = MatchType.Wildcards; model.ResponseType = ResponseType.Redirect; model.RequestedUrl = "*/"; model.RedirectStatus = RedirectStatusCode.MovedPermanently; switch (redirectGroup) { case RedirectRuleGroup.None: break; case RedirectRuleGroup.Product: var product = await _productService.FindByIdAsync(entityId); model.ResponseUrl = await RemoveLanguageFromUrl(Url.Action("Index", "Product", new { slug = product.Slug, area = "" })); break; case RedirectRuleGroup.BlogPost: var blogPost = await _blogPostService.FindByIdAsync(entityId); model.ResponseUrl = await RemoveLanguageFromUrl(Url.Action("Post", "Blog", new { slug = blogPost.Slug, area = "" })); break; case RedirectRuleGroup.Page: var page = await _pagesService.FindByIdAsync(entityId); model.ResponseUrl = await RemoveLanguageFromUrl(Url.Action("Index", "Page", new { slug = page.Slug, area = "" })); break; default: throw new ArgumentOutOfRangeException(); } } model.EntityId = entityId; model.RedirectGroup = redirectGroup; return(View(model)); }
public virtual async Task <ActionResult> Editor(int?id) { if (id != null) { var record = await _pagesService.FindByIdAsync(id.Value); if (record != null) { return(View(await _pageModelFactory.PreparePageModelAsync(record))); } } return(View(await _pageModelFactory.PreparePageModelAsync(null))); }