Beispiel #1
0
        public async Task AddAsync(GameBll entity)
        {
            if (!IsValidGame(entity))
            {
                throw new ValidationException($"The game is not valid");
            }

            if (await GetGameByKeyAsync(entity.Key) != null)
            {
                throw new ValidationException($"The game with the key: {entity.Key} is already exist");
            }

            var game = MapperBll.Map <Game>(entity);

            await ProjectGenresToDAlAsync(game.Genres, entity.Genres);
            await ProjectPlatformTypesToDAlAsync(game.PlatformTypes, entity.PlatformTypes);

            try
            {
                _gameRepository.Add(game);
                await Database.CommitAsync();
            }
            catch (Exception ex)
            {
                throw new AccessException($"Can not add game {entity.Key} to database", "", ex);
            }
        }
Beispiel #2
0
        public async Task UpdateAsync(GameBll entity)
        {
            if (!IsValidGame(entity))
            {
                return;
            }

            var game = await GetGameByKeyAsync(entity.Key);

            if (game == null)
            {
                throw new ValidationException($"The game {entity.Key} is not exist");
            }

            MapperBll.Map(entity, game);
            await ProjectGenresToDAlAsync(game.Genres, entity.Genres);
            await ProjectPlatformTypesToDAlAsync(game.PlatformTypes, entity.PlatformTypes);

            try
            {
                _gameRepository.Update(game);
                await Database.CommitAsync();
            }
            catch (Exception ex)
            {
                throw new AccessException($"Can not add game {entity.Key} to database", "", ex);
            }
        }
Beispiel #3
0
        private bool IsValidGame(GameBll gameToValidate)
        {
            var errors = new Dictionary <string, string>();

            if (gameToValidate == null)
            {
                errors.Add("", "Empty game");
            }
            else
            {
                if (string.IsNullOrEmpty(gameToValidate.Key))
                {
                    errors.Add("Key", "Key is required.");
                }
                if (string.IsNullOrEmpty(gameToValidate.Name))
                {
                    errors.Add("Name", "Name is required.");
                }
            }
            if (errors.Count != 0)
            {
                throw new ValidationException("The game is not valid");
            }

            return(true);
        }
        public ActionResult  GameAllData()
        {
            int    pageSize  = int.Parse(Request["pageSize"] ?? "25");
            int    pageIndex = int.Parse(Request["pageIndex"] ?? "1");
            int    total     = 0;
            string games     = Request["games"];
            string type      = Request["type"];
            string theme     = Request["theme"];
            string play      = Request["play"];
            string letter    = Request["letter"];
            string key       = Request["key"];

            GameParam param = new GameParam()
            {
                PageIndex = pageIndex,
                PageSize  = pageSize,
                Total     = total,
                GameName  = key,
                Games     = games,
                Theme     = theme,
                Type      = type,
                Play      = play,
                Letter    = letter,
            };
            var list = GameBll.GetAllGamesInfo(param).ToList();

            var NavStr = Common.LaomaPager.ShowPageNavigate(param.PageSize, param.PageIndex, param.Total);
            var result = new { Data = list, NavStr = NavStr };

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
        public ActionResult GameNameListPartial()
        {
            var data = GameBll.LoadEntities(n => n.Id > 0).Select(n => new GameName {
                Name = n.Name
            }).ToList();

            ViewBag.GameName = data;
            return(PartialView("GameNameListPartial"));
        }
Beispiel #6
0
        public RootForm(RootController controller)
        {
            InitializeComponent();
            var       players   = controller.CreateDefaultPlayers();
            var       gameID    = GameBll.Instance().CreateGame(players);
            var       game      = GameBll.Instance().FindById(gameID);
            ArenaView arenaView = new ArenaView(controller, game, players);

            this.Controls.Add(arenaView);
        }
        public ActionResult RolePlay()
        {
            var    param    = CommonPaging();
            string rolePlay = GameType.RolePlay.ToString();

            ViewData["RolePlay"]  = GameBll.GetAllTypeGame(rolePlay, param).ToList();
            ViewData["pageIndex"] = param.PageIndex;
            ViewData["pageSize"]  = param.PageSize;
            ViewData["Total"]     = param.Total;
            return(View());
        }
 public ActionResult GameIndex()
 {
     //轮播推荐区:总后台游戏推荐管理,热门推荐。最多显示8个
     ViewBag.RecHotGame = GameBll.LoadEntities(g => g.State == "1" && g.Rec_Hot == "1").OrderByDescending(g => g.Rec_Hot_Time).Select(g => new GameViewModel2()
     {
         Id     = g.Id,
         BigImg = g.BigImg
     }).Take(8).ToList();
     //seo推荐游戏
     ViewBag.RecSeoGame = SeoBll.GetSeoData(3, "2");
     return(View());
 }
Beispiel #9
0
        public ActionResult AllGameName(string gameName)
        {
            //数据匹配  有数据 不提示、不匹配直接提示

            var allGameName = GameBll.LoadEntities(g => g.Name == gameName).Select(g => new { g.Name }).FirstOrDefault();

            if (allGameName != null)
            {
                return(Content("ok"));
            }
            else
            {
                return(Content("no"));
            }
        }
Beispiel #10
0
        public IEnumerable <TableRecord> CalculateTable(Tourney tourney)
        {
            if (tourney == null)
            {
                return(new TableRecord[] { });
            }

            var gameBll = new GameBll();

            IEnumerable <Game> games = gameBll.GetGamesByTourney(tourney.Id);

            short rule = tourney?.tourneyTypeId ?? 1;

            return(CalculateTable(rule, games, tourney.Id));
        }
        public ActionResult GameDetail(int id)
        {
            ViewData.Model             = GameBll.LoadEntities(g => g.Id == id).FirstOrDefault();
            ViewBag.GameRelatedNews    = GameBll.GetGameRelatedNews(id);
            ViewBag.GameRelatedRaiders = GameBll.GetGameRelatedRaiders(id);

            //相关开服
            ViewBag.GameRelatedService     = GameBll.GetGameRelatedService(id);
            ViewData["GameRelatedPackage"] = GameBll.GetGameRelatedPackage(id);
            //福利--游戏试玩
            ViewBag.GameRelatedDemo = GameBll.GetGameRelatedDemo(id);
            //游戏截图
            ViewBag.GameCutImg = GameBll.GetGameCutImgInfo(id);
            //该游戏相关推荐同类型游戏随机显示
            ViewBag.GameRelatedType = GameBll.GetGameSameTypeData(id);
            //联运
            ViewBag.CpyGame = GameBll.GetGameCpy(id);
            return(View());
        }
        public ActionResult GameLikePlusOne(int id)
        {
            var game = GameBll.LoadEntities(g => g.Id == id).FirstOrDefault();

            if (game != null)
            {
                game.LikeNum = game.LikeNum == null?1:game.LikeNum + 1;
                if (GameBll.Update(game))
                {
                    return(Content("ok"));
                }
                else
                {
                    return(Content("no"));
                }
            }
            else
            {
                return(Content("noExist"));
            }
        }
        public ActionResult GameSearch(string key)
        {
            int         pageSize  = int.Parse(Request["pageSize"] ?? "25");
            int         pageIndex = int.Parse(Request["pageIndex"] ?? "1");
            int         total     = 0;
            Guid        cacheKey  = Guid.NewGuid();
            List <Game> list      = null;
            object      obj       = Common.CacheHelper.Get(cacheKey.ToString());

            if (obj == null)
            {
                list = GameBll.LoadPageEntities(pageSize, pageIndex, out total, g => g.Name.Contains(key) || g.Alias.Contains(key), false, g => g.InTime).ToList().Select(g => new Game()
                {
                    Name    = g.Name,
                    Id      = g.Id,
                    DescImg = g.DescImg
                }).ToList();
                if (list != null)
                {
                    try
                    {
                        Common.CacheHelper.WriteCache(cacheKey.ToString(), list, DateTime.Now.AddMinutes(10));
                    }
                    catch (Exception)
                    {
                        throw new Exception("缓存异常,需要处理!");
                    }
                }
            }
            else
            {
                list = obj as List <Game>;
            }
            //搜索结果
            ViewData["GameSearch"] = list;
            ViewData["pageIndex"]  = pageIndex;
            ViewData["pageSize"]   = pageSize;
            ViewData["Total"]      = total;
            return(PartialView("GameSearch"));
        }
 public ActionResult Index()
 {
     ViewData["smallImg"]   = AdvertisementBll.GetAllTypeAdvert("2", 9);
     ViewData["advert"]     = AdvertisementBll.GetAllTypeAdvert("3", 2);
     ViewBag.IndexBigImg    = AdvertisementBll.GetAllTypeAdvert("1", 1);
     ViewBag.SiYe           = AdvertisementBll.GetAllTypeAdvert("4", 1);
     ViewData["recGame"]    = HomePageBll.GetAllTypeHomePage("11", 11);
     ViewData["joinCpy"]    = HomePageBll.GetAllTypeHomePage("12", 13);
     ViewData["SlideShow"]  = HomePageBll.GetAllTypeHomePage("7", 10);
     ViewData["TenTopArea"] = HomePageBll.GetAllTypeHomePage("10", 10);
     //网站首页所有新闻类型
     ViewData["allTypeNews"] = NewsBll.GetAllNewsIndex();
     //开测
     ViewData["TestInfo"] = TestBll.TestDataTen();
     //最爽礼包
     ViewData["NewestCoolPackage"] = PackageBll.NewestCoolPackage();
     //最热游戏
     ViewData["NewestHotGame"] = HomePageBll.GetAllTypeHomePage("13", 5);
     // 最强福利
     ViewBag.NewsetGameDemo = GameDemoBll.GetNewestGameDemo();
     //直播热点
     ViewData["DirectHot"]      = HomePageBll.GetAllTypeHomePage("5", 1);
     ViewData["threeDirectHot"] = NewsBll.AccondingTypeGetNews("5");
     //手游
     ViewData["MobileGame"]      = HomePageBll.GetAllTypeHomePage("6", 1);
     ViewData["threeMobileGame"] = NewsBll.AccondingTypeGetNews("6");
     //最赞攻略结合游戏库拿游戏的logo图
     ViewData["MostGreatRaiders"] = UserRaidersBll.GetMostGreatRaiders(10);
     //福利美图
     ViewData["NewestIndexRecGirls"] = BeautifulGirlsBll.NewestIndexRecGirls();
     //热游排行
     ViewBag.InLikeNumHotGame = GameBll.InLikeNumHotGame();
     //开服
     ViewBag.sevenData = OpenServiceBll.WillSevenDayService();
     //资讯排行
     ViewBag.LikeNumNews = NewsBll.InLikeNumNews();
     ViewBag.RecCpy      = CompanyBll.RecCompany();
     return(View());
 }
Beispiel #15
0
        private static GameBll GetGameBllWithDetails()
        {
            var game = new GameBll
            {
                Id            = 1,
                Description   = "TestDescription1",
                Key           = "TestKey1",
                Name          = "TestName1",
                PlatformTypes = new List <PlatformTypeBll>
                {
                    new PlatformTypeBll {
                        Id = 1, Type = "Mobile"
                    },
                    new PlatformTypeBll {
                        Id = 2, Type = "Desktop"
                    },
                    new PlatformTypeBll {
                        Id = 4, Type = "Browser"
                    }
                },
                Genres = new List <GenreBll>
                {
                    new GenreBll {
                        Id = 4, Name = "Strategy"
                    },
                    new GenreBll {
                        Id = 3, Name = "Sports"
                    },
                    new GenreBll {
                        Id = 1, Name = "Adventure"
                    }
                }
            };

            return(game);
        }
Beispiel #16
0
        public ActionResult GameName()
        {
            var allGameName = GameBll.LoadEntities(g => true).Select(g => new { g.Name });

            return(Json(allGameName, JsonRequestBehavior.AllowGet));
        }
Beispiel #17
0
 public ActionResponse PressCell(int gameID, int x, int y)
 {
     return(GameBll.Instance().PressCell(new ActionRequest {
         GameId = gameID, PositionX = x, PositionY = y
     }));
 }
 public ActionResult _CityDataList()
 {
     ViewBag.AllCity = GameBll.GetAllCity();
     return(PartialView("_CityDataList"));
 }