public ActionResult Index()
 {
     HahaVilleContext db = new HahaVilleContext();
     List<Category> listOfCategory = db.Category.ToList();
     List<Game> listOfGames = listOfCategory[0].Games.ToList();
     List<User> listOfUsers = db.Users.ToList();
     return View(listOfGames);
 }
Exemple #2
0
        public ActionResult Index()
        {
            HahaVilleContext db = new HahaVilleContext();
            List<Category> listOfCategory = db.Category.ToList();
            List<Game> listOfGames = new List<Game>();
            List<GameInfo> listOfGameInfos = new List<GameInfo>();
            foreach (var category in listOfCategory)
            {
                listOfGames.AddRange((from g in db.Games
                                      where g.Category.Id == category.Id
                                      select g).Take(4));
            }

            int[] arrOfGameIds = null;
            arrOfGameIds = listOfGames.Select(x => x.Id).ToArray();

            LocalizedProperty[] arrProps = (from props in db.LocalizedProperties
                                            where arrOfGameIds.Contains(props.EntityId) &&
                                                  props.LanguageId == 1
                                            select props).ToArray();

            foreach (var category in listOfCategory)
            {
                foreach (var game in listOfGames.Where(x => x.CategoryId == category.Id))
                {
                    LocalizedProperty[] arrGameProps = arrProps.Where(x => x.EntityId == game.Id).ToArray();
                    GameInfo objGI = new GameInfo() { Id = game.Id,
                                                      LanguageId = 1,
                                                      CategoryId = category.Id,
                                                      Thumbnail = game.Thumbnail,
                                                      Uri = game.GamePath};
                    if (arrGameProps.Length > 0)
                    {
                        LocalizedProperty lpName = arrGameProps.Where(x => x.LocaleKey.Equals("game.name")).FirstOrDefault();
                        LocalizedProperty lpTitle = arrGameProps.Where(x => x.LocaleKey.Equals("game.metatitle")).FirstOrDefault();
                        LocalizedProperty lpDesc = arrGameProps.Where(x => x.LocaleKey.Equals("game.desc")).FirstOrDefault();
                        LocalizedProperty lpKeyword = arrGameProps.Where(x => x.LocaleKey.Equals("game.metakeyword")).FirstOrDefault();
                        LocalizedProperty lpCatName = arrGameProps.Where(x => x.LocaleKey.Equals("category.name")).FirstOrDefault();

                        objGI.Name = lpName != null ? lpName.LocaleValue : string.Empty;
                        objGI.Title = lpTitle != null ? lpTitle.LocaleValue : string.Empty;
                        objGI.Description = lpDesc != null ? StringHtmlExtensions.TruncateHtml(lpDesc.LocaleValue, 90, "... <br /> <a href=\"games/" + game.Name.Replace(" ","-") + "\" >(View Details)</a>") : string.Empty;
                        objGI.Keyword = lpKeyword != null ? lpKeyword.LocaleValue : string.Empty;
                        objGI.CategoryName = lpCatName != null ? lpCatName.LocaleValue : category.Name;

                    }
                    listOfGameInfos.Add(objGI);
                }

            }

            //List<User> listOfUsers = db.Users.ToList();
            return View(listOfGameInfos);
        }
Exemple #3
0
        public static IReadOnlyCollection<SitemapNode> GetSitemapNodes(UrlHelper urlHelper)
        {
            List<SitemapNode> nodes = new List<SitemapNode>();

            nodes.Add(
                new SitemapNode()
                {
                    Url = urlHelper.AbsoluteContent("/Home"),
                    Priority = 1
                });
            nodes.Add(
               new SitemapNode()
               {
                   Url = urlHelper.AbsoluteContent("/Home/About"),
                   Priority = 0.9
               });

             HahaVilleContext db = new HahaVilleContext();
             var listOfGategories = (from c in db.Category
                                     select c.Name.Replace(" ", "-"));
                foreach (var cat in listOfGategories)
            {
                nodes.Add(
                   new SitemapNode()
                   {
                       Url = urlHelper.AbsoluteRouteUrl("Category", new { action = "Category", name = cat }),
                       Frequency = SitemapFrequency.Monthly,
                       Priority = 0.9
                   });
                }

             var objTargetGame = (from g in db.Games
                                  select
                                      g.Name.Replace(" ", "-")
                                  );
             foreach (var game in objTargetGame)
            {
                nodes.Add(
                   new SitemapNode()
                   {
                       Url = urlHelper.AbsoluteRouteUrl("Game", new { action = "Details", name = game }),
                       Frequency = SitemapFrequency.Weekly,
                       Priority = 0.8
                   });
                nodes.Add(
                new SitemapNode()
                {
                    Url = urlHelper.AbsoluteRouteUrl("Play", new { action = "Play", name = game }),
                    Frequency = SitemapFrequency.Weekly,
                    Priority = 0.8
                });
            }

            nodes.Add(
               new SitemapNode()
               {
                   Url = urlHelper.AbsoluteContent("/Home/Contact"),
                   Priority = 0.7
               });

            return nodes;
        }
Exemple #4
0
        public ActionResult Details(string name)
        {
            //int nGameId = 0;
            GameInfo objGI = null;
            //if (int.TryParse(name, out nGameId))
            //{
            HahaVilleContext db = new HahaVilleContext();
            var objTargetGame = (from g in db.Games
                                 where g.Name == name.Replace("-", " ")
                                 select new
                                 {
                                     Id = g.Id,
                                     Thumbnail = g.Thumbnail,
                                     Uri = g.GamePath,
                                     CategoryId = g.CategoryId,
                                     Props = g.LocalizedProperties,
                                 }).FirstOrDefault();

            if (objTargetGame != null)
            {
                objGI = new GameInfo()
                {
                    Id = objTargetGame.Id,
                    LanguageId = 1,
                    CategoryId = objTargetGame.CategoryId,
                    Thumbnail = objTargetGame.Thumbnail,
                    Uri = objTargetGame.Uri,
                };

                if (objTargetGame.Props != null && objTargetGame.Props.Count > 0)
                {
                    LocalizedProperty lpName = objTargetGame.Props.Where(x => x.LocaleKey.Equals("game.name")).FirstOrDefault();
                    LocalizedProperty lpTitle = objTargetGame.Props.Where(x => x.LocaleKey.Equals("game.metatitle")).FirstOrDefault();
                    LocalizedProperty lpDesc = objTargetGame.Props.Where(x => x.LocaleKey.Equals("game.desc")).FirstOrDefault();
                    LocalizedProperty lpKeyword = objTargetGame.Props.Where(x => x.LocaleKey.Equals("game.metakeyword")).FirstOrDefault();
                    LocalizedProperty lpCatName = objTargetGame.Props.Where(x => x.LocaleKey.Equals("category.name")).FirstOrDefault();

                    objGI.Name = lpName != null ? lpName.LocaleValue : string.Empty;
                    objGI.Title = lpTitle != null ? lpTitle.LocaleValue : string.Empty;
                    objGI.Description = lpDesc != null ? lpDesc.LocaleValue : string.Empty;
                    objGI.Keyword = lpKeyword != null ? lpKeyword.LocaleValue : string.Empty;
                    objGI.CategoryName = lpCatName != null ? lpCatName.LocaleValue : string.Empty;

                }
            }
            //}

            if (objGI != null)
            {
                return View(objGI);
            }
            else
            {
                return RedirectToAction("Index", "Home");
            }
        }
Exemple #5
0
        public ActionResult Category(string name)
        {
            HahaVilleContext db = new HahaVilleContext();
            List<GameInfo> listOfGameInfo = (from c in db.Category
                                             join g in db.Games on c.Id equals g.CategoryId into cg
                                             from lg in cg
                                             where lg.Category.Name == name
                                             select new GameInfo
                                             {
                                                 Id = lg.Id,
                                                 LanguageId = 1,
                                                 Thumbnail = lg.Thumbnail,
                                                 Uri = lg.GamePath,
                                                 CategoryId = lg.CategoryId,
                                                 CategoryName = lg.Category.Name
                                             }).ToList();

            if (listOfGameInfo.Count > 0)
            {
                int categoryID = listOfGameInfo.Select(x => x.CategoryId).FirstOrDefault();

                int[] arrOfGameIds = listOfGameInfo.Select(x => x.Id).ToArray();
                List<LocalizedProperty> listOfCategoryLocalizedProps = (from props in db.LocalizedProperties
                                                                where props.EntityId == categoryID &&
                                                                      props.LanguageId == 1
                                                                select props).ToList();

                foreach (var p in listOfCategoryLocalizedProps)
                {
                    switch (p.LocaleKey)
                    {
                        case "category.name":
                            ViewBag.Name = p.LocaleValue;
                            break;
                        case "category.metatitle":
                            ViewBag.metatitle = p.LocaleValue;
                            break;
                        case "category.metakeyword":
                            ViewBag.metakeyword = p.LocaleValue;
                            break;
                        case "category.metadesc":
                            ViewBag.metadesc = p.LocaleValue;
                            break;
                    }
                }

                List<LocalizedProperty> listOfGamesLocalizedProps = (from props in db.LocalizedProperties
                                                                where arrOfGameIds.Contains(props.EntityId) &&
                                                                      props.LanguageId == 1
                                                                select props).ToList();

                foreach (var objGI in listOfGameInfo)
                {
                    var prop = listOfGamesLocalizedProps.Where(x => x.EntityId == objGI.Id);
                    foreach (var p in prop)
                    {
                        switch (p.LocaleKey)
                        {
                            case "game.name":
                                objGI.Name = p.LocaleValue;
                                break;
                            case "game.metatitle":
                                objGI.Title = p.LocaleValue;
                                break;
                            case "game.desc":
                                objGI.Description = StringHtmlExtensions.TruncateHtml(p.LocaleValue, 90, "... <br /> <a href=\"/games/" + objGI.Name.Replace(" ", "-") + "\" >(View Details)</a>");
                                break;
                            //case "game.metakeyword":
                            //    objGI.Keyword = p.LocaleValue;
                            //    break;
                            //case "category.name":
                            //    objGI.CategoryName = p.LocaleValue;
                            //    break;
                            default:
                                break;
                        }
                    }
                }
            }

            return View(listOfGameInfo);
        }