Exemple #1
0
        public ActionResult Index()
        {
            CategoryListingViewModel model = new CategoryListingViewModel();

            model.Categories      = categoriesService.GetAllCategories();
            model.PageTitle       = "Categories";
            model.PageDescription = "Categories Listing Page";
            return(View(model));
        }
Exemple #2
0
        public async Task <CategoryListingViewModel> GetAllCategoriesAsync()
        {
            var categories = await dbContext
                             .Categories
                             .Include(x => x.Posts)
                             .ToListAsync();

            var categoryModel = mapper
                                .Map <IEnumerable <CategoryConciseViewModel> >(categories); //Map

            var model = new CategoryListingViewModel
            {
                CategoryListing = categoryModel
            };

            return(model);
        }
        public async Task GetByIdGenericWorks()
        {
            await this.SeedDatabase();

            var expected = new CategoryListingViewModel
            {
                Id            = this.testCategory1.Id,
                Title         = this.testCategory1.Title,
                Description   = this.testCategory1.Description,
                ImageUrl      = this.testCategory1.ImageUrl,
                HasRecentPost = true,
            };

            var result = await this.service.GetByIdAsync <CategoryListingViewModel>(this.testCategory1.Id);

            var expectedObj     = JsonConvert.SerializeObject(expected);
            var actualResultObj = JsonConvert.SerializeObject(result);

            // I am serializing the objects to ensure that Assert.Equal won't compare any
            // internal properties that I am not trying to compare in this test
            Assert.Equal(expectedObj, actualResultObj);
        }
Exemple #4
0
        public ActionResult Listing()
        {
            CategoryListingViewModel model = new CategoryListingViewModel();

            return(PartialView(model));
        }