Example #1
0
 public static BlogSettings Get(IRepository repo)
 {
     return repo.List<BlogSettings>().Single();
 }
Example #2
0
File: Post.cs Project: BjartN/Blog
 public static IQueryable<Post> GetPublishedPosts(IRepository repository)
 {
     //TODO: Limitation in current version of the Norm driver. Need to pull everything
     return repository.List<Post>()
         .Where(x => x.IsPublished).ToList()
         .OrderByDescending(x => x.Created).AsQueryable();
 }
Example #3
0
File: Post.cs Project: BjartN/Blog
 public static IQueryable<Tag> GetTags(IRepository repository)
 {
     //TODO: Nasty. Need to deal with m-m relationships in some way....
     var posts = repository.List<Post>().ToList();
     var tags = new List<Tag>();
     foreach(var post in posts)
     {
         tags = tags.Union(post.Tags).Distinct().ToList();
     }
     return tags.AsQueryable();
 }
        private static void GenerateRouteDirectionReals(Route route, IRepository rep)
        {
            Dictionary<string, Route> s_routes = null;
            if (s_routes == null)
            {
                var routes = rep.List<Route>();
                s_routes = new Dictionary<string, Route>();
                foreach (var i in routes)
                {
                    s_routes[i.Name] = i;
                }
            }
            string realRoute = route.DirectionExpression;
            if (string.IsNullOrEmpty(route.DirectionExpression))
            {
                route.DirectionReal = null;
                return;
            }

            string[] subRoute = route.DirectionExpression.Split(new char[] {'|', '(', ')' }, StringSplitOptions.RemoveEmptyEntries);

            for (int i = 0; i < subRoute.Length; ++i)
            {
                string s = subRoute[i].Trim();
                if (s_routes.ContainsKey(s))
                {
                    if (string.IsNullOrEmpty(s_routes[s].DirectionReal))
                    {
                        GenerateRouteDirectionReals(s_routes[s], rep);
                    }
                    if (string.IsNullOrEmpty(s_routes[s].DirectionReal))
                    {
                        throw new ArgumentException(string.Format("There is no route named of {0}", subRoute[i]));
                    }
                    realRoute = realRoute.Replace(subRoute[i], s_routes[subRoute[i]].DirectionReal);
                }
            }
            route.DirectionReal = realRoute;
        }