Beispiel #1
0
        public ArticleController(ISectionService sectionService, IArticleService articleService, IHtmlParserHelper htmlParserHelper, ICustomUrlService customUrlService)
        {
            _sectionService   = sectionService;
            _articleService   = articleService;
            _customUrlService = customUrlService;
            _htmlParserHelper = htmlParserHelper;

            _fakeArticleDraftRepository  = new FakeArticleDraftRepository(articleService);
            _fakeArticlePubRepository    = new FakeArticlePubRepository(articleService);
            _fakeArticlePubReqRepository = new FakeArticlePubReqRepository(articleService);
        }
Beispiel #2
0
 public SectionController(ISectionService sectionService, ICustomUrlService customUrlService)
 {
     _sectionService        = sectionService;
     _customUrlService      = customUrlService;
     _fakeSectionRepository = new FakeSectionRepository(_sectionService, _customUrlService);
 }
Beispiel #3
0
 internal FakeSectionRepository(ISectionService sectionService, ICustomUrlService customUrlService)
 {
     _sectionService   = sectionService;
     _customUrlService = customUrlService;
 }
        protected override IHttpHandler GetHttpHandler(System.Web.Routing.RequestContext requestContext)
        {
            string    controller = String.Empty;
            string    action     = String.Empty;
            int       page;
            string    path;
            CustomUrl customUrl = null;

            var fullUrl = ((string)requestContext.RouteData.Values["url"]).ToLower();

            if (TryParseUrl(fullUrl, out path, out page))
            {
                if (CustomUrlCache.CustomUrls.ContainsKey(path))
                {
                    customUrl = CustomUrlCache.CustomUrls[path];
                }
                else
                {
                    ICustomUrlService customUrlService = (ICustomUrlService)DependencyResolver.Current.GetService(typeof(ICustomUrlService));

                    customUrl = customUrlService.GetAll().FirstOrDefault(x => String.Equals(x.Url, path, StringComparison.CurrentCultureIgnoreCase));
                    if (customUrl != null)
                    {
                        CustomUrlCache.CustomUrls.TryAdd(path, customUrl);
                    }
                }

                if (customUrl != null)
                {
                    switch (customUrl.ContentType)
                    {
                    case ContentType.Article:
                        controller = "Post";
                        action     = "Article";
                        break;

                    case ContentType.Section:
                        controller = "Home";
                        action     = "Section";
                        requestContext.RouteData.Values["page"] = page;
                        break;

                    default:
                        throw new ArgumentException("Invalid ContentType");
                    }
                }
            }

            if (customUrl == null)
            {
                controller = "Common";
                action     = "NoPageFound";
            }
            else
            {
                requestContext.RouteData.Values["id"] = customUrl.ContentId;
            }
            requestContext.RouteData.DataTokens.Add("namespaces", new string[] { "ZelectroCom.Web.Controllers" });
            requestContext.RouteData.Values["controller"] = controller;
            requestContext.RouteData.Values["action"]     = action;

            return(base.GetHttpHandler(requestContext));
        }