示例#1
0
        public async Task <IActionResult> Index()
        {
            // Main slides home
            var filterMainSlide = Builders <Slide> .Filter.Eq(x => x.SlideType, StaticVar.MainSlide);

            var filterSubSlide = Builders <Slide> .Filter.Eq(x => x.SlideType, StaticVar.SubSlide);

            ViewBag.Slides = await _slide.FilterByAsync(filterMainSlide);

            ViewBag.SubSlides = await _slide.FilterByAsync(filterSubSlide);

            // Join with customer to show avatar !!???
            var collectionComment = _comment._collection;
            var comments          = collectionComment.Aggregate()
                                    .Lookup("CustomerTest", "Customer", "_id", "ObjCustomers")
                                    .As <Comment>()
                                    .ToList();

            ViewBag.Comments = comments;

            // Blogs
            var news = _news.AsQueryable().Where(x => x.IsActive == true).OrderByDescending(x => x.Id).Take(2);

            ViewBag.News = news;

            // Books
            var books = _book.AsQueryable().Where(x => x.IsActive == true).OrderByDescending(x => x.Id).Take(8);

            ViewBag.Books = books;
            return(View());
        }
示例#2
0
        public async Task <IViewComponentResult> InvokeAsync()
        {
            var filterCategory = Builders <Category> .Filter.Eq(x => x.IsActive, true);

            ProjectionDefinition <Category, dynamic> projectCategory = new FindExpressionProjectionDefinition <Category, dynamic>(p => new
            {
                Code = p.Code.ToLower(),
                p.Name
            });

            var category = await _category.FilterByAsync(filterCategory, projectCategory);

            ViewBag.Category = category;

            var filterConfig = Builders <Config> .Filter.Eq(x => x.IsActive, true)
                               & Builders <Config> .Filter.Eq(x => x.Code, "bookstore");

            var config = await _config.FindOneAsync(filterConfig);

            ViewBag.Config = config;

            return(View());
        }