Exemplo n.º 1
0
        private dynamic GetJob()
        {
            var model = this.Bind <JobBindingModel>();
            var vm    = viewProjectionFactory.Get <JobBindingModel, JobViewModel>(model);

            return(Response.AsJson(new { success = vm.Success, model = vm.Model }));
        }
Exemplo n.º 2
0
 private void SetTagCloud(NancyContext obj)
 {
     ViewBag.TagCould =
         _viewFactory.Get <TagCloudBindingModel, TagCloudViewModel>(new TagCloudBindingModel()
     {
         Threshold = 2
     });
 }
Exemplo n.º 3
0
        private int GetNewJobCount()
        {
            var vm = viewProjectionFactory.Get <AllJobsBindingModel, AllJobsViewModel>(new AllJobsBindingModel {
                StartDate = DateTime.Now.GetStartDateTimeOfDay()
            });

            return(vm.TotalCount);
        }
Exemplo n.º 4
0
        private dynamic GetPerformanceList()
        {
            var model = this.Bind <AllPerformancesBindingModel>();
            var vm    = viewProjectionFactory.Get <AllPerformancesBindingModel, AllPerformancesViewModel>(model);

            return(Response.AsJson(vm));
        }
Exemplo n.º 5
0
        private Response SetCurrentUserToViewBag(NancyContext ctx)
        {
            var author = _viewProjectionFactory.Get <string, Author>(ctx.CurrentUser.UserName);

            ViewBag.CurrentUser = author;

            return(null);
        }
Exemplo n.º 6
0
        private dynamic GetRecentPostsRss()
        {
            var recentPosts = _viewProjectionFactory.Get <RecentBlogPostsBindingModel, RecentBlogPostsViewModel>(new RecentBlogPostsBindingModel()
            {
                Page = 1,
                Take = 30
            });

            return(new RssResponse(recentPosts.Posts, Settings.WebsiteName, new Uri(Settings.WebsiteUrl)));
        }
Exemplo n.º 7
0
        private Response SetCurrentUserToViewBag(NancyContext ctx)
        {
            var author = _viewProjectionFactory.Get <string, Author>(ctx.CurrentUser.UserName);

            if (author == null)
            {
                return(ctx.GetRedirect("/mz-login?returnUrl=" + Request.Url.Path).AddCookie(FormsAuthentication.CreateLogoutCookie()));
            }

            ViewBag.CurrentUser = author;
            return(null);
        }
Exemplo n.º 8
0
        private dynamic GetRecentPostsRss()
        {
            var cacheKey = "rss";
            var rss      = _cache.Get <RssResponse>(cacheKey);

            if (rss == null)
            {
                var recentPosts = _viewProjectionFactory.Get <RecentBlogPostsBindingModel, RecentBlogPostsViewModel>(new RecentBlogPostsBindingModel()
                {
                    Page = 1,
                    Take = 30
                });

                rss = new RssResponse(recentPosts.Posts, Settings.WebsiteName, new Uri(AppConfiguration.Current.SiteUrl));
                _cache.Add(cacheKey, rss, 60 * 5);
            }
            return(rss);
        }
Exemplo n.º 9
0
 public static Tag AsTag(this string slug)
 {
     return(_viewFac.Get <string, Tag>(slug));
 }
Exemplo n.º 10
0
        public static Tag AsTag(this string tag)
        {
            var slug = tag.ToSlug();

            return(factory.Get <string, Tag>(slug));
        }