Exemplo n.º 1
0
        /// <summary>
        /// Returns all ad data from the server
        /// </summary>
        /// <returns></returns>
        private static List <Ad> GetAdsFromServer()
        {
            AdDataServiceClient client = new AdDataServiceClient();
            DateTime            start  = new DateTime(2011, 1, 1);
            DateTime            end    = new DateTime(2011, 5, 1);

            return(client.GetAdDataByDateRange(start, end).ToList <Ad>());
        }
Exemplo n.º 2
0
 public override void LoadAds(DateTime start, DateTime end)
 {
     var client = new AdDataServiceClient();
     var ads = client.GetAdDataByDateRange(start, end);
     var viewModelAds =
         ads.Select(a => Models.Ad.Create(a.AdId, a.Brand.BrandId, a.Brand.BrandName, a.NumPages, a.Position));
     Ads = viewModelAds.OrderBy(a=>a.BrandName).ToList();
 }
Exemplo n.º 3
0
        private Ad[] GetAdsDataList()
        {
            AdDataServiceClient adc = new AdDataServiceClient();

            Ad[] retAdList = adc.GetAdDataByDateRange(FromDate, ToDate);
            adc.Close();
            return(retAdList);
        }
Exemplo n.º 4
0
        public override void LoadAds(DateTime start, DateTime end)
        {
            var client       = new AdDataServiceClient();
            var ads          = client.GetAdDataByDateRange(start, end);
            var viewModelAds =
                ads.Select(a => Models.Ad.Create(a.AdId, a.Brand.BrandId, a.Brand.BrandName, a.NumPages, a.Position));

            Ads = viewModelAds.OrderBy(a => a.BrandName).ToList();
        }
        public AdServiceContainer()
        {
            this.bjk_fromDate        = new DateTime(2011, 1, 1, 0, 0, 0);
            this.bjk_toDate          = new DateTime(2011, 4, 1, 23, 59, 59);
            this.bjk_exercise_number = ExerciseNumber.EXERCISE_1;

            bjk_client = new AdDataServiceClient();
            bjk_ads    = bjk_client.GetAdDataByDateRange(this.bjk_fromDate, this.bjk_toDate).ToList();
            bjk_client.Close();
        }
Exemplo n.º 6
0
        }//index

        //
        public ActionResult FullListAd(int? page, string sortBy = "BrandName", string sortOrder = "", int pageSize = 200, string currentSortBy = "", string currentSortByDir = "")
        {
            try
            {
                if (sortOrder == "")
                    ViewBag.SortDirParm = "desc";

                else
                    ViewBag.SortDirParm = sortOrder == "asc" ? "desc" : "asc";

                ViewBag.CurrentSortBy = sortBy;
                ViewBag.CurrentSortByDir = sortOrder;

                var sortExpression = String.Format("{0} {1}", sortBy, sortOrder);
                int pgNum = (page ?? 1);
                ViewBag.CurrentPage = pgNum;

                startDate = DateTime.Parse(sDate);
                endDate = DateTime.Parse(eDate);

                AdDataServiceClient ad = new AdDataServiceClient();
                var fullList = ad.GetAdDataByDateRange(startDate, endDate).ToList();

                switch(sortBy)
                {
                    case "BrandName":
                        fullList = sortOrder == "desc" ? fullList.OrderByDescending(b => b.Brand.BrandName).ToList() : fullList.OrderBy(b => b.Brand.BrandName).ToList();
                        break;
                    case "AdId":
                        fullList = sortOrder == "desc" ? fullList.OrderByDescending(a => a.AdId).ToList() : fullList.OrderBy(a => a.AdId).ToList();
                        break;
                    case "BrandId":
                        fullList = sortOrder == "desc" ? fullList.OrderByDescending(b => b.Brand.BrandId).ToList() : fullList.OrderBy(b => b.Brand.BrandId).ToList();
                        break;
                    case "NumPages":
                        fullList = sortOrder == "desc" ? fullList.OrderByDescending(n => n.NumPages).ToList() : fullList.OrderBy(n => n.NumPages).ToList();
                        break;
                    case "Position":
                        fullList = sortOrder == "desc" ? fullList.OrderByDescending(p => p.Position).ToList() : fullList.OrderBy(p => p.Position).ToList();
                        break;
                }

                return View("FullListAd", fullList.ToPagedList(pgNum, pageSize));
            }
            catch (Exception ex)
            {
                return View(ex.Message.ToString());
            }
        }//FullListAd
Exemplo n.º 7
0
        private static List <Ad> GetAdData(DateTime startDate, DateTime endDate)
        {
            var adDataService = new AdDataServiceClient();

            return(adDataService.GetAdDataByDateRange(startDate, endDate));
        }
Exemplo n.º 8
0
        }//FullListAd

        public ActionResult CoverAdList(int? page, string sortBy = "BrandName", string sortOrder = "",
            int pageSize = 200, string currentSortBy = "", string currentSortByDir = "")
        {
            if (sortOrder == "")
                ViewBag.SortDirParm = "desc";

            else
                ViewBag.SortDirParm = sortOrder == "asc" ? "desc" : "asc";

            ViewBag.CurrentSortBy = sortBy;
            ViewBag.CurrentSortByDir = sortOrder;

            int pgNum = (page ?? 1);
            ViewBag.CurrentPage = pgNum;

            startDate = DateTime.Parse(sDate);
            endDate = DateTime.Parse(eDate);

            AdDataServiceClient ad = new AdDataServiceClient();
            var cl = ad.GetAdDataByDateRange(startDate, endDate);

            var coverList = (from c in cl
                            where c.Position == "Cover" && c.NumPages >= 0.5M
                            //orderby c.Brand.BrandName ascending
                            select c).ToList();
            switch (sortBy)
            {
                case "BrandName":
                    coverList = sortOrder == "desc" ? coverList.OrderByDescending(b => b.Brand.BrandName).ToList() : coverList.OrderBy(b => b.Brand.BrandName).ToList();
                    break;
                case "AdId":
                    coverList = sortOrder == "desc" ? coverList.OrderByDescending(a => a.AdId).ToList() : coverList.OrderBy(a => a.AdId).ToList();
                    break;
                case "BrandId":
                    coverList = sortOrder == "desc" ? coverList.OrderByDescending(b => b.Brand.BrandId).ToList() : coverList.OrderBy(b => b.Brand.BrandId).ToList();
                    break;
                case "NumPages":
                    coverList = sortOrder == "desc" ? coverList.OrderByDescending(n => n.NumPages).ToList() : coverList.OrderBy(n => n.NumPages).ToList();
                    break;
                case "Position":
                    coverList = sortOrder == "desc" ? coverList.OrderByDescending(p => p.Position).ToList() : coverList.OrderBy(p => p.Position).ToList();
                    break;
            }

            return View(coverList.ToPagedList(pgNum, pageSize));

        }//CoverAdList
Exemplo n.º 9
0
        }//topFiveAds

        public ActionResult topFiveBrands()
        {
            startDate = DateTime.Parse(sDate);
            endDate = DateTime.Parse(eDate);

            AdDataServiceClient ad = new AdDataServiceClient();
            var tBrands = ad.GetAdDataByDateRange(startDate, endDate);

            var tBrand = (from t in tBrands                          
                          orderby t.NumPages descending, t.Brand.BrandName
                          select t).Take(5);

            return View(tBrand.ToList());

        }//topFiveBrands
Exemplo n.º 10
0
        }//CoverAdList

        public ActionResult topFiveAds()
        {
            startDate = DateTime.Parse(sDate);
            endDate = DateTime.Parse(eDate);

            AdDataServiceClient ad = new AdDataServiceClient();
            var tAds = ad.GetAdDataByDateRange(startDate, endDate);

            var tfivead = (from t in tAds
                           orderby t.NumPages descending, t.Brand.BrandName
                           select t).Distinct().Take(5);

            //var tfiveAds = tfivead.GroupBy(b => b.Brand.BrandName)
            //               .Select(g => g.ToList())
            //               .ToList()
            //               .Distinct().Take(5);

            return View(tfivead.ToList());
        }//topFiveAds
 public HomeController()
 {
     var client = new AdDataServiceClient();
     data = client.GetAdDataByDateRange(new DateTime(2011, 1, 1),
         new DateTime(2011, 4, 1));
 }