public JsonEntertainment magazineList()
        {
            JsonEntertainment             jsonEntertainment = new JsonEntertainment();
            EntertainmentViewModel        tolinkobj         = new EntertainmentViewModel();
            List <EntertainmentViewModel> tolinklistobj     = new List <EntertainmentViewModel>();

            try
            {
                var listEntertainment = _entertainment.entertainmentmagazineId();
                foreach (var item in listEntertainment)
                {
                    tolinkobj.TypeId    = item.Type;
                    tolinkobj.Name      = item.Name;
                    tolinkobj.LinkId    = _links.FindById(item.LId).Url;
                    tolinkobj.Galleryid = item.Galleryid;
                    tolinkobj.Title     = item.Title;
                    tolinklistobj.Add(tolinkobj);
                }
                jsonEntertainment.Result = tolinklistobj;
                return(jsonEntertainment);
            }
            catch (Exception ex)
            {
                _ = ex.Message;
                return(jsonEntertainment);
            }
        }
示例#2
0
        public ActionResult Index()
        {
            _viewModel = new EntertainmentViewModel();
            CreateLayoutView("Giải trí");
            LayoutViewModel lay = ViewModel;

            return(View(ViewModel));
        }
示例#3
0
        public ActionResult Edit(int id)
        {
            Entertainment model = this.entertainments.GetById(id);

            if (model != null)
            {
                EntertainmentViewModel modelVM = Mapper.Map <EntertainmentViewModel>(model);
                return(View(modelVM));
            }

            return(this.RedirectToAction("Index"));
        }
示例#4
0
        public ActionResult Create(EntertainmentViewModel model)
        {
            if (ModelState.IsValid)
            {
                Entertainment ent = Mapper.Map <Entertainment>(model);
                this.entertainments.Add(ent);
                this.entertainments.SaveChanges();

                return(RedirectToAction("Index"));
            }

            return(View(model));
        }
示例#5
0
        public ActionResult Details(string entertainmentId)
        {
            Entertainment current = this.entertainments.GetById(int.Parse(entertainmentId));

            if (current != null)
            {
                EntertainmentViewModel currentVM  = this.Mapper.Map <EntertainmentViewModel>(current);
                IEnumerable <string>   facilities = current.Facilities.Split('|');
                ViewBag.Facilities = facilities;
                return(View(currentVM));
            }

            return(this.RedirectToAction("Index", "Home"));
        }
示例#6
0
        public ActionResult Edit(EntertainmentViewModel model)
        {
            if (ModelState.IsValid)
            {
                Entertainment current = this.entertainments.GetById(model.Id);
                this.entertainments.Detach(current);
                Entertainment edited = Mapper.Map <Entertainment>(model);
                this.entertainments.Update(edited);
                this.entertainments.SaveChanges();

                return(RedirectToAction("Index"));
            }

            return(View());
        }
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     base.OnNavigatedTo(e);
     viewModel   = new EntertainmentViewModel();
     DataContext = viewModel;
 }
示例#8
0
        // GET: Home
        public ActionResult Index()
        {
            PostViewModel postViewModel = new PostViewModel();
            var           homePost      = postManager.GetAll().OrderByDescending(c => c.Id);


            var politicsPost = homePost.Where(c => c.Category.Name == "Politics");

            var             datas           = homePost.OrderByDescending(c => c.Id).FirstOrDefault(c => c.Category.Name == "Politics");
            BannerViewModel bannerViewModel = new BannerViewModel()
            {
                Id          = datas.Id,
                Title       = datas.Title,
                Description = datas.Description,
                ImagePath   = datas.ImagePath,
                Tags        = datas.Tags,
                PostDate    = datas.PostDate
            };

            List <SiteBannerViewModel> siteBannerViewModels = new List <SiteBannerViewModel>();
            var siteBannder = homePost.Where(c => c.Category.Name == "Politics").OrderByDescending(c => c.Id).Skip(1).Take(2);

            foreach (var data in siteBannder)
            {
                var siteBannerVM = new SiteBannerViewModel()
                {
                    Id          = data.Id,
                    Title       = data.Title,
                    Description = data.Description,
                    ImagePath   = data.ImagePath
                };
                siteBannerViewModels.Add(siteBannerVM);
            }

            /*banner Bottom post*/
            List <BannerBottomViewModel> bannerBottomViewModels = new List <BannerBottomViewModel>();
            var BannerBottom = homePost.Where(c => c.Category.Name == "Politics").OrderByDescending(c => c.Id).Skip(3).Take(4);

            foreach (var data in BannerBottom)
            {
                var bannerBottomVM = new BannerBottomViewModel()
                {
                    Id          = data.Id,
                    Title       = data.Title,
                    Description = data.Description,
                    ImagePath   = data.ImagePath,
                    PostDate    = data.PostDate.ToString("d")
                };
                bannerBottomViewModels.Add(bannerBottomVM);
            }
            postViewModel.BannerBottomViewModels = bannerBottomViewModels;
            /*banner Bottom post*/

            /*latest Post */
            List <LatestPostViewModel> latestPostViewModels = new List <LatestPostViewModel>();
            var latestPost = homePost.Where(c => c.Category.Name == "Politics").OrderByDescending(c => c.Id).Skip(7).Take(7);

            foreach (var data in latestPost)
            {
                var latestPostVM = new LatestPostViewModel()
                {
                    Id          = data.Id,
                    Title       = data.Title,
                    Description = data.Description,
                    ImagePath   = data.ImagePath
                };
                latestPostViewModels.Add(latestPostVM);
            }
            postViewModel.LatestPostViewModels = latestPostViewModels;
            /*latest Post */

            /*popular Post */
            var popularPost = homePost.Skip(14).Take(4);
            List <PopularPostViewModel> popularPostViewModels = new List <PopularPostViewModel>();

            foreach (var data in popularPost)
            {
                var popularPostVM = new PopularPostViewModel()
                {
                    Id        = data.Id,
                    Title     = data.Title,
                    PostDate  = data.PostDate.ToString("d"),
                    ImagePath = data.ImagePath,
                    Category  = data.Category
                };
                popularPostViewModels.Add(popularPostVM);
            }
            postViewModel.PopularPostViewModels = popularPostViewModels;
            /*popular Post */

            /*Sports Post */
            var entertainmentPost = homePost.Where(c => c.Category.Name == "Entertainment").OrderByDescending(c => c.Id).Take(4);
            List <EntertainmentViewModel> entertainmentViewModels = new List <EntertainmentViewModel>();

            foreach (var data in entertainmentPost)
            {
                var entertainmentVM = new EntertainmentViewModel()
                {
                    Id          = data.Id,
                    Title       = data.Title,
                    ImagePath   = data.ImagePath,
                    Description = data.Description,
                    PostDate    = data.PostDate.ToString("D")
                };
                entertainmentViewModels.Add(entertainmentVM);
            }
            postViewModel.EntertainmentViewModels = entertainmentViewModels;
            /*Sports Post */



            /*Sports Post */
            var sportsPost = homePost.Where(c => c.Category.Name == "Sports").OrderByDescending(c => c.Id).Take(4);
            List <SportsViewModel> sportsViewModels = new List <SportsViewModel>();

            foreach (var data in sportsPost)
            {
                var sportsVM = new SportsViewModel()
                {
                    Id          = data.Id,
                    Title       = data.Title,
                    ImagePath   = data.ImagePath,
                    Description = data.Description,
                    PostDate    = data.PostDate.ToString("D")
                };
                sportsViewModels.Add(sportsVM);
            }
            postViewModel.SportsViewModels = sportsViewModels;
            /*Sports Post */


            /*technology Post */
            var techPost = homePost.OrderByDescending(c => c.Id).FirstOrDefault(c => c.Category.Name == "Technology");
            TechnologyViewModel technologyViewModel = new TechnologyViewModel()
            {
                Id          = techPost.Id,
                Title       = techPost.Title,
                Description = techPost.Description,
                PostDate    = techPost.PostDate.ToString("D"),
                ImagePath   = techPost.ImagePath
            };

            postViewModel.TechnologyViewModel = technologyViewModel;
            /*technology Post */

            /*education Post */
            var educationPost = homePost.OrderByDescending(c => c.Id).FirstOrDefault(c => c.Category.Name == "Education");
            EducationViewModel educationViewModel = new EducationViewModel()
            {
                Id          = educationPost.Id,
                Title       = educationPost.Title,
                Description = educationPost.Description,
                ImagePath   = educationPost.ImagePath,
                PostDate    = educationPost.PostDate.ToString("D")
            };

            postViewModel.EducationViewModel = educationViewModel;
            /*education Post */

            /*travel Post */
            var             travelPost      = homePost.OrderByDescending(c => c.Id).FirstOrDefault(c => c.Category.Name == "Travel");
            TravelViewModel travelViewModel = new TravelViewModel()
            {
                Id          = travelPost.Id,
                Title       = travelPost.Title,
                Description = travelPost.Description,
                ImagePath   = travelPost.ImagePath,
                PostDate    = travelPost.PostDate.ToString("D")
            };

            postViewModel.TravelViewModel = travelViewModel;
            /*travel Post */


            /*food Post */
            var           foodPost      = homePost.OrderByDescending(c => c.Id).FirstOrDefault(c => c.Category.Name == "Food");
            FoodViewModel foodViewModel = new FoodViewModel()
            {
                Id          = foodPost.Id,
                Title       = foodPost.Title,
                Description = foodPost.Description,
                ImagePath   = foodPost.ImagePath,
                PostDate    = foodPost.PostDate.ToString("D")
            };

            postViewModel.FoodViewModel = foodViewModel;
            /*food Post */

            /*health Post */
            var             healthPost      = homePost.OrderByDescending(c => c.Id).FirstOrDefault(c => c.Category.Name == "Health");
            HealthViewModel healthViewModel = new HealthViewModel()
            {
                Id          = healthPost.Id,
                Title       = healthPost.Title,
                Description = healthPost.Description,
                ImagePath   = healthPost.ImagePath,
                PostDate    = healthPost.PostDate.ToString("D")
            };

            postViewModel.HealthViewModel = healthViewModel;
            /*health Post */


            /*economics Post */
            var economicsPost = homePost.OrderByDescending(c => c.Id).FirstOrDefault(c => c.Category.Name == "Economics");
            EconomicsViewModel economicsViewModel = new EconomicsViewModel()
            {
                Id          = economicsPost.Id,
                Title       = economicsPost.Title,
                Description = economicsPost.Description,
                ImagePath   = economicsPost.ImagePath,
                PostDate    = economicsPost.PostDate.ToString("D")
            };

            postViewModel.EconomicsViewModel = economicsViewModel;
            /*economics Post */

            postViewModel.BannerViewModel      = bannerViewModel;
            postViewModel.SiteBannerViewModels = siteBannerViewModels;

            return(View(postViewModel));
        }