コード例 #1
0
        // GET: Admin/Advertisements
        public IActionResult Index()
        {
            var advertisements = advertisementservice.GetAdvertisements().ToList();

            ViewBag.Advertisements = advertisements;
            return(View(advertisements));
        }
コード例 #2
0
        //GET: Home page
        public IActionResult HomePage()
        {
            HomePageViewModel homePageViewModel = new HomePageViewModel();

            var suppliers      = SupplierService.GetAll();
            var supplierModels = Mapper.Map <IEnumerable <Supplier>, IEnumerable <SupplierModel> >(suppliers);

            homePageViewModel.SupplierModels = supplierModels.ToList();

            var products      = ProductService.GetAllProducts();
            var productModels = Mapper.Map <IEnumerable <Product>, IEnumerable <ProductModel> >(products).ToList();


            homePageViewModel.ProductModels = RemoveProduct(productModels);

            var categories     = CategoryService.GetAllCategoriesAndSub();
            var categoryModels = Mapper.Map <IEnumerable <Category>, IEnumerable <CategoryModel> >(categories);

            homePageViewModel.CategoryModels = categoryModels.ToList();

            var advertisements      = AdvertisementService.GetAdvertisements();
            var advertisementModels = Mapper.Map <IEnumerable <Advertisement>, IEnumerable <AdvertisementModel> >(advertisements);

            homePageViewModel.AdvertisementModels = advertisementModels.ToList();

            return(View(homePageViewModel));
        }
コード例 #3
0
        public IViewComponentResult Invoke()
        {
            var advertisements      = AdvertisementService.GetAdvertisements();
            var advertisementModels = Mapper.Map <IEnumerable <Advertisement>,
                                                  IEnumerable <AdvertisementModel> >(advertisements);

            return(View("Advertisement", advertisementModels));
        }