示例#1
0
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.
            ApplyConfigurationsFromAssembly
                (typeof(EduZbieraczContext).Assembly);



            foreach (var item in DummyCategories.Get())
            {
                modelBuilder.Entity <Category>().HasData(item);
            }

            foreach (var item in DummyPosts.Get())
            {
                modelBuilder.Entity <Post>(b =>
                {
                    b.HasData(item);
                    //b.OwnsOne(e => e.Category).HasData(item.Category);
                });

                //modelBuilder.Entity<Post>().HasData(item);
                //modelBuilder.owns
            }

            foreach (var item in DummyWebinars.Get())
            {
                modelBuilder.Entity <Webinar>().HasData(item);
            }
        }
示例#2
0
        public Task <List <Post> > Handle(GetAllPostsQuery request, CancellationToken cancellationToken)
        {
            var posts = DummyPosts.Get();

            if (request.OrderBy == OrderByPostOptions.ByAuthor)
            {
                return(Task.FromResult
                           (posts.OrderBy(p => p.Author).ToList()));
            }
            else if (request.OrderBy == OrderByPostOptions.ByDate)
            {
                return(Task.FromResult
                           (posts.OrderBy(p => p.Date).ToList()));
            }
            else if (request.OrderBy == OrderByPostOptions.ByTitle)
            {
                return(Task.FromResult
                           (posts.OrderBy(p => p.Title).ToList()));
            }

            return(Task.FromResult
                       (posts));
        }