public ActionResult DetailsComingSoon(int id)
        {
            AccountService service  = new AccountService(db, null);
            int            MemberID = 0;

            if (Request.IsAuthenticated)
            {
                MemberID = service.findMember(User.Identity.Name).MemberID;
            }

            ProductInGame pigs = db.ProductInGames.Where(x => x.GameID == id).First();

            if (pigs.Game.GameState.ToLower() == "completed")
            {
                return(Redirect("/"));
            }
            ProductDisplayViewModel pdvm = new ProductDisplayViewModel(MemberID, pigs.GameID);

            pdvm.Product = pigs.Product;
            pdvm.images  = pigs.Product.Imagedetails.Where(w => w.ImageTypeID == 3);


            //TODO: DS: What are therules for which p.i.g. to select/display here
            GameDao gd = new GameDao(db);
            List <GameListViewModel> otherGames = gd.getOtherGames(MemberID, pigs.Game.MemberSubscriptionType);

            otherGames.RemoveAll(g => g.gameID == id);
            pdvm.CurrentProductInGame = pigs;
            pdvm.otherGames           = otherGames;

            return(View(pdvm));
        }
Example #2
0
        public static GameInfo GetModelByGameId(string keyWord)
        {
            GameInfo modelByGameId = new GameDao().GetModelByGameId(keyWord);

            Globals.EntityCoding(modelByGameId, false);
            return(modelByGameId);
        }
Example #3
0
        public ActionResult Video(int id)
        {
            GameDao gameDao = new GameDao();
            Game    g       = gameDao.GetById(id);

            return(View(g));
        }
Example #4
0
 /// <summary>
 /// Zwróć wszystkie jednostkowe pola dla danej gry.
 /// </summary>
 /// <param name="gameDao">gra</param>
 /// <param name="message">wiadomośc, przekazywana w razie porażki</param>
 /// <returns></returns>
 public static List <BoardElementLocationDao> GetAllBlocksForGame(GameDao gameDao, out String message)
 {
     try
     {
         message = null;
         List <BoardElementLocationDao> blocks = new List <BoardElementLocationDao>();
         var query = from element in DataManager.DataBaseContext.BoardElementLocations
                     where element.Game.Id == gameDao.Id &&
                     (element.BoardElement.ElementType == BoardElementType.BlackBlock ||
                      element.BoardElement.ElementType == BoardElementType.GrayBlock ||
                      element.BoardElement.ElementType == BoardElementType.WhiteBlock ||
                      element.BoardElement.ElementType == BoardElementType.RedBlock)
                     orderby element.XLocation, element.YLocation
         select element;
         BoardElementLocation[] bElements = query.ToArray();
         for (int i = 0; i < bElements.Length; i++)
         {
             BoardElementLocationDao block =
                 Mapper.Map <BoardElementLocation, BoardElementLocationDao>(bElements[i]);
             blocks.Add(block);
         }
         return(blocks);
     }
     catch (Exception e)
     {
         var declaringType = MethodBase.GetCurrentMethod().DeclaringType;
         if (declaringType != null)
         {
             Logger.LogMessage(declaringType.Name, MethodBase.GetCurrentMethod().Name,
                               e.StackTrace);
         }
         message = e.Message;
     }
     return(null);
 }
Example #5
0
        // GET: Games
        public ActionResult Index(int?page)
        {
            int itemsOnPage = 4;
            int pg          = page.HasValue ? page.Value : 1;
            int totalGames;

            GameDao      gameDao = new GameDao();
            IList <Game> games   = gameDao.GetGamesPaged(itemsOnPage, pg, out totalGames);

            ViewBag.Pages       = (int)Math.Ceiling((double)totalGames / (double)itemsOnPage);
            ViewBag.CurrentPage = pg;

            ViewBag.Categories = new GameCategoryDao().GetAll();

            HernaUser user = new HernaUserDao().GetByLogin(User.Identity.Name);

            if (user.Role.Identificator == "hrac")
            {
                return(View("IndexHrac", games));
            }

            if (Request.IsAjaxRequest())
            {
                return(PartialView(games));
            }

            return(View(games));
        }
Example #6
0
        public override void makeCompleted()
        {
            if (game.NextGameID != null)
            {
                Game newGame = db.Games.Find(game.NextGameID);
                if (newGame != null)
                {
                    GameDao gameDao = new GameDao(db);
                    IEnumerable <MembersWhoPlayed> nonWinnersQ = gameDao.findMembersWhoPlayed(game.GameID);

                    List <MemberInGame> nonWinners = new List <MemberInGame>();

                    foreach (MembersWhoPlayed nonWinner in nonWinnersQ)
                    {
                        MemberInGame memberingame = new MemberInGame();
                        memberingame.GameID       = newGame.GameID;
                        memberingame.MemberID     = nonWinner.MemberID;
                        memberingame.DateInserted = DateTime.Now;
                        memberingame.DateUpdated  = DateTime.Now;
                        memberingame.USR          = "******";
                        //   memberingame.WinIndicator = false;
                        memberingame.PaymentIndicator = false;
                        nonWinners.Add(memberingame);
                    }
                    newGame.MemberInGames = nonWinners;

                    db.SaveChanges();
                    FFFGame mygame = new FFFGame(db, scheduler, newGame);

                    //  mygame.makeActive();
                    mygame.makeActive();
                }
            }
            base.makeCompleted();
        }
        public ActionResult DetailDeveloper(int id)
        {
            GameDao gameDao = new GameDao();
            Game    g       = gameDao.GetById(id);

            return(View(g));
        }
Example #8
0
        public ActionResult Category2(int id)
        {
            IList <Game> games = new GameDao().GetGamesInCategoryId(id);

            ViewBag.Categories = new GameCategoryDao().GetAll();
            return(View("Index", games));
        }
Example #9
0
        public ActionResult addPolozku(int idhra, int idobjednavka)
        {
            PolozkaObjednavkaDao polozkaObjednavkaDao = new PolozkaObjednavkaDao();
            PolozkaObjednavka    polozka = new PolozkaObjednavka();
            GameDao gameDao = new GameDao();
            Hra     hra     = gameDao.GetById(idhra);

            polozka.Hra          = hra;
            polozka.Mnozstvi     = 1;
            polozka.ObjednavkaID = idobjednavka;
            polozka.TehdejsiCena = hra.aktualniCenasDPH();
            polozka.Stav         = new StavDao().GetById(8);
            polozka.Aktivovano   = true;
            ObjednavkaDao objednavkaDao = new ObjednavkaDao();
            Objednavka    objednavka    = objednavkaDao.GetById(idobjednavka);

            polozkaObjednavkaDao.Create(polozka);


            objednavka.Polozky = polozkaObjednavkaDao.getbyObjednavka(objednavka.Id);
            objednavka.prepocet();

            objednavkaDao.Update(objednavka);
            return(RedirectToAction("DetailObjednavky", new { id = objednavka.Id }));
            //return Redirect(ControllerContext.HttpContext.Request.UrlReferrer.ToString());
        }
Example #10
0
 /// <summary>
 /// Zwróć rozmieszczenie wszystkich bonusów dla zadanej gry.
 /// </summary>
 /// <param name="gameDao">gra</param>
 /// <param name="message">wiadomośc, przekazywana w razie porażki</param>
 /// <returns></returns>
 public static List <BoardElementLocationDao> GetAllBonusesForGame(GameDao gameDao, out String message)
 {
     try
     {
         message = null;
         List <BoardElementLocationDao> bonuses = new List <BoardElementLocationDao>();
         var query = from element in DataManager.DataBaseContext.BoardElementLocations
                     where (element.BoardElement.ElementType == BoardElementType.BombAmountBonus ||
                            element.BoardElement.ElementType == BoardElementType.FastBonus ||
                            element.BoardElement.ElementType == BoardElementType.InmortalBonus ||
                            element.BoardElement.ElementType == BoardElementType.PointBonus ||
                            element.BoardElement.ElementType == BoardElementType.SlowBonus ||
                            element.BoardElement.ElementType == BoardElementType.StrenghtBonus) &&
                     element.Game.Id == gameDao.Id
                     select element;
         BoardElementLocation[] bElements = query.ToArray();
         for (int i = 0; i < bElements.Length; i++)
         {
             BoardElementLocationDao block = Mapper.Map <BoardElementLocationDao>(bElements[i]);
             bonuses.Add(block);
         }
         return(bonuses);
     }
     catch (Exception e)
     {
         var declaringType = MethodBase.GetCurrentMethod().DeclaringType;
         if (declaringType != null)
         {
             Logger.LogMessage(declaringType.Name, MethodBase.GetCurrentMethod().Name,
                               e.StackTrace);
         }
         message = e.Message;
     }
     return(null);
 }
Example #11
0
 /// <summary>
 /// Zwróć wszytskie elementy z planszy dla zadanej gry.
 /// </summary>
 /// <param name="gameDao">gra</param>
 /// <param name="message">wiadomośc, przekazywana w razie porażki</param>
 /// <returns></returns>
 public static List <BoardElementLocationDao> GetAllBoardElementsForGame(GameDao gameDao, out String message)
 {
     try
     {
         message = null;
         List <BoardElementLocationDao> elements = new List <BoardElementLocationDao>();
         var query = from element in DataManager.DataBaseContext.BoardElementLocations
                     select element;
         if (query.Any())
         {
             List <BoardElementLocation> list = query.ToList();
             list.All(x =>
             {
                 elements.Add(Mapper.Map <BoardElementLocationDao>(x));
                 return(true);
             });
             return(elements);
         }
         return(null);
     }
     catch (Exception e)
     {
         var declaringType = MethodBase.GetCurrentMethod().DeclaringType;
         if (declaringType != null)
         {
             Logger.LogMessage(declaringType.Name, MethodBase.GetCurrentMethod().Name,
                               e.StackTrace);
         }
         message = e.Message;
     }
     return(null);
 }
Example #12
0
 /// <summary>
 /// Zwróć Lokalizację wszystkich przeciwników w zależności od wybranej gry.
 /// </summary>
 /// <param name="gameDao">gra</param>
 /// <param name="message">wiadomość przesyłana w razie niepowodzenia</param>
 /// <returns></returns>
 public static List <OpponentLocationDao> GetAllOponentsWithLocationsByGame(GameDao gameDao, out String message)
 {
     try
     {
         message = null;
         List <OpponentLocationDao> opponentLocation = new List <OpponentLocationDao>();
         var query = from element in DataManager.DataBaseContext.OponentLocations
                     where element.Game.Id == gameDao.Id
                     select element;
         OpponentLocation[] bElements = query.ToArray();
         for (int i = 0; i < bElements.Length; i++)
         {
             OpponentLocationDao opponentL = Mapper.Map <OpponentLocationDao>(bElements[i]);
             opponentLocation.Add(opponentL);
         }
         return(opponentLocation);
     }
     catch (Exception e)
     {
         var declaringType = MethodBase.GetCurrentMethod().DeclaringType;
         if (declaringType != null)
         {
             Logger.LogMessage(declaringType.Name, MethodBase.GetCurrentMethod().Name,
                               e.StackTrace);
         }
         message = e.Message;
     }
     return(null);
 }
Example #13
0
        public ActionResult Index()//ComingSoon()
        {
            int                        MemberId  = 0;
            AccountService             service   = new AccountService(db, null);
            HomeAuthenticatedViewModel mainModel = new HomeAuthenticatedViewModel();

            if (Request.IsAuthenticated)
            {
                MemberId = service.findMember(User.Identity.Name).MemberID;
                List <MyVaultItemViewModel> topSectionList = FindTopSectionList(MemberId);

                mainModel.TopSection = topSectionList.OrderBy(x => x.GameScheduleStart).Take(10);
                //3.Get Upcoming Vault Items

                List <MyVaultItemViewModel> upcomingVaultItemList = new List <MyVaultItemViewModel>();
                //TODO : Get Vault Items
                mainModel.UpcomingVaultItems = topSectionList.OrderBy(x => x.GameScheduleStart).Take(10);
            }
            GameService gameService = new GameService(db);
            List <ComingSoonViewModel> ComingSoonList = ToCommingSoon(gameService.FindComingSoonGames(MemberId));

            if (ComingSoonList.All(c => c.ComingSoonGameVM.Count() == 0) && MemberId != 0)
            {
                ComingSoonList = ToCommingSoon(gameService.findGlobalGames(MemberId));
            }
            mainModel.ComingSoon = ComingSoonList;
            GameDao        gd          = new GameDao(db);
            List <dynamic> recentSales = gd.findRecentWinners();

            mainModel.recentWinners = recentSales;
            return(View(mainModel));
        }
Example #14
0
        // GET: Hra
        public ActionResult Hra(int?_page, int?_itemsOnPage, bool?vse)
        {
            int         celkem;
            bool        _vse        = vse.HasValue ? vse.Value : false;
            int         itemsOnPage = _itemsOnPage.HasValue ? _itemsOnPage.Value : Utilityzer.DefaultCountPerPage;
            int         page        = _page.HasValue ? _page.Value : 1;
            GameDao     gameDao     = new GameDao();
            IList <Hra> ucty        = gameDao.getPaged2(itemsOnPage, page, out celkem, _vse);

            //foreach (Hra item in ucty)
            //{
            //    if (item.Platforma.Aktivovano == false || item.Vydavatel.Aktivovano == false)
            //        ucty.Remove(item);
            //}


            ViewBag.pages    = (int)Math.Ceiling((double)celkem / (double)itemsOnPage);
            ViewBag.soucasna = page;
            ViewBag.vse      = vse;
            ViewBag.perPage  = itemsOnPage;
            ViewBag.celkem   = celkem;

            if (Request.IsAjaxRequest())
            {
                return(PartialView("HraAjax", ucty));
            }

            return(View(ucty));
        }
Example #15
0
        // GET: Games
        public ActionResult Index()
        {
            GameDao      gameDao = new GameDao();
            IList <Game> games   = gameDao.GetAll();

            return(View(games));
        }
Example #16
0
        [HttpPost] //aby nikdo nemohl to udělat přes url
        public ActionResult delete(String _id, int?_page, int?_itemsOnPage, bool?vse)
        {
            int     id      = int.Parse(_id);
            GameDao gameDao = new GameDao();
            Hra     hra     = gameDao.GetById(id);

            if (hra.Ikona != null)
            {
                try
                {
                    System.IO.File.SetAttributes(Server.MapPath("~/uploads/hry/" + hra.Ikona), FileAttributes.Normal);
                    System.IO.File.Delete(Server.MapPath("~/uploads/hry/" + hra.Ikona));
                }
                catch (Exception e)
                {
                }
            }

            PlatformaDao platformaDao = new PlatformaDao();

            VydavatelDao vydavateleDao = new VydavatelDao();

            TempData["message-success"] = "Hra " + hra.Nazev + "byla upravena.";
            Vydavatel vydavatel = hra.Vydavatel;
            Platforma platforma = hra.Platforma;

            platforma.Pocet--;
            vydavatel.Pocet--;
            platformaDao.Update(platforma);
            vydavateleDao.Update(vydavatel);
            gameDao.Delete(hra);
            return(RedirectToAction("Hra"));
        }
Example #17
0
        public ActionResult AddObrazek(Obrazek obrazek, string hra, HttpPostedFileBase obr)
        {
            GameDao gameDao = new GameDao();
            Hra     hra1    = gameDao.GetById(int.Parse(hra));

            obrazek.Game = hra1;

            if (obr != null)
            {
                if (obr.ContentType == "image/jpeg" || obr.ContentType == "image/png")

                {
                    Image image = Image.FromStream(obr.InputStream);
                    if (image.Height > 200 || image.Width > 200)
                    {
                        Image smallImage = ImageHelper.ScaleImage(image, 1080, 960);

                        Bitmap b         = new Bitmap(smallImage);
                        Guid   guid      = Guid.NewGuid();
                        string imageName = guid.ToString() + ".jpg";
                        b.Save(Server.MapPath("~/uploads/hry/" + imageName), ImageFormat.Jpeg);
                        smallImage.Dispose();
                        b.Dispose();
                        if (obrazek.Ikona != null)
                        {
                            try
                            {
                                System.IO.File.SetAttributes(Server.MapPath("~/uploads/hry/" + obrazek.Ikona), FileAttributes.Normal);
                                System.IO.File.Delete(Server.MapPath("~/uploads/hry/" + obrazek.Ikona));
                            }
                            catch (Exception e)
                            {
                            }
                        }

                        obrazek.Ikona = imageName;
                    }
                    else
                    {
                        obrazek.Ikona = Server.MapPath("~´/uploads/hry/" + obr.FileName);
                        obr.SaveAs(Server.MapPath("~´/uploads/hry/" + obr.FileName));
                    }
                    ObrazekDao obrazekDao = new ObrazekDao();
                    obrazekDao.Create(obrazek);
                    TempData["message-success"] = "Přidán obrázek";

                    return(RedirectToAction("DetailHry", new{ id = obrazek.Game.Id }));
                }
                else
                {
                    TempData["err"] = "Chybí obrázek, nebo není typu JPG / PNG";
                    return(View("pridatObrazek", obrazek));
                }
            }


            TempData["err"] = "Něco se pokazilo";
            return(View("pridatObrazek", obrazek));
        }
Example #18
0
        public override GameResolveStatus resolvePotentialWinners()
        {
            GameDao gameDao = new GameDao(db);
            IEnumerable <ProductPlayed> gameResults = gameDao.findProductPlayeds(game.ProductInGames.First().ProductInGameID);  //winner = 0 and orderd highest to lowest

            resolve(gameResults);
            return(game.GameState.ToUpper() != "COMPLETED" ? GameResolveStatus.OUTSTANDING : GameResolveStatus.RESOLVED);
        }
 private Game ConvertGameDao(GameDao gameDao)
 {
     return(new Game()
     {
         Id = gameDao.Id,
         Name = gameDao.Name
     });
 }
Example #20
0
        public static bool UpdateStatus(int gameId, GameStatus status)
        {
            bool flag = new GameDao().UpdateStatus(gameId, status);

            if (flag)
            {
            }
            return(flag);
        }
Example #21
0
        public ActionResult SearchPlatforma(int id)
        {
            int         celkem;
            GameDao     hraDao = new GameDao();
            IList <Hra> ucty   = hraDao.GetByPlatforma2(id, out celkem, false);

            celkem         = ucty.Count;
            ViewBag.celkem = celkem;
            return(View("Hra", ucty));
        }
Example #22
0
        public ActionResult Search(string nazev)
        {
            int         celkem;
            GameDao     hraDao = new GameDao();
            IList <Hra> ucty   = hraDao.SearchName3(nazev);

            celkem         = ucty.Count;
            ViewBag.celkem = celkem;
            return(PartialView("HraAjax", ucty));
        }
Example #23
0
        public ActionResult SearchVydavatel(int id)
        {
            int         celkem;
            GameDao     hraDao = new GameDao();
            IList <Hra> ucty   = hraDao.GetByVydavatel(id, out celkem, true);

            celkem         = ucty.Count;
            ViewBag.celkem = celkem;
            return(View("Hra", ucty));
        }
Example #24
0
        public ActionResult SearchProPolozku(string nazev, int?id)
        {
            int         celkem;
            GameDao     hraDao = new GameDao();
            IList <Hra> ucty   = hraDao.SearchName(nazev);

            celkem               = ucty.Count;
            ViewBag.celkem       = celkem;
            ViewBag.objednavkaid = id;
            return(PartialView("PridatPolozkuAjax", ucty));
        }
Example #25
0
        public ActionResult Edit(int id)
        {
            GameDao         gameDao         = new GameDao();
            GameCategoryDao gameCategoryDao = new GameCategoryDao();

            Game g = gameDao.GetById(id);

            ViewBag.Categories = gameCategoryDao.GetAll();

            return(View(g));
        }
Example #26
0
        public ActionResult pridatObrazek(int id_hry)
        {
            GameDao gameDao = new GameDao();
            Hra     hra     = gameDao.GetById(id_hry);
            Obrazek novy    = new Obrazek();

            novy.Game       = hra;
            novy.Aktivovano = true;

            return(View(novy));
        }
Example #27
0
        // TODO move login to game.. to resuse rule across games

        /*       public void restart()
         *     {
         *         if (game.restart == true)
         *         {
         *             Game newGame = new Game();
         *             newGame.DateInserted = new DateTime();
         *             newGame.DateUpdated = new DateTime();
         *             newGame.GameCode = game.GameCode;
         *             newGame.GameTypeID = game.GameTypeID;
         *             newGame.GameName = game.GameName;
         *             newGame.NumberOfWinners = game.NumberOfWinners;
         *             newGame.NextGameID = game.NextGameID;
         *             newGame.MemberSubscriptionType = game.MemberSubscriptionType;
         *             newGame.Global = game.Global;
         *             newGame.restart = false;
         *             GameDao gameDao = new GameDao(db);
         *             gameDao.save(newGame);
         *
         *             ICollection<GameRule> newGameRules = add3Mins(game.GameRules.ToList(), newGame.GameID);
         *             GameRuleDao gameRuleDao = new GameRuleDao(db);
         *             gameRuleDao.save(newGameRules);
         *
         *             newGame.MemberInGames = gameDao.findLosers(game.GameID);
         *             game.NextGameID = newGame.GameID;
         *             db.SaveChanges();
         *
         *             reschedule5MinDeal(gameDao, newGame.NextGameID);
         *         }
         *     }
         */

        private void reschedule5MinDeal(GameDao gameDao, int?gameID)
        {
            if (gameID != null)
            {
                Game fiveMinGame = gameDao.findGame(gameID);
                foreach (GameRule gameRule in fiveMinGame.GameRules)
                {
                    gameRule.ExcecuteTime.AddMinutes(3);
                }
                gameDao.save();
            }
        }
Example #28
0
        public ActionResult Update(Game game, HttpPostedFileBase picture, int categoryId)
        {
            try
            {
                GameDao         gameDao         = new GameDao();
                GameCategoryDao gameCategoryDao = new GameCategoryDao();

                GameCategory gameCategory = gameCategoryDao.GetById(categoryId);

                game.Category = gameCategory;

                if (picture != null)
                {
                    if (picture.ContentType == "image/jpeg" || picture.ContentType == "image/png")
                    {
                        Image image = Image.FromStream(picture.InputStream);

                        Guid   guid      = Guid.NewGuid();
                        string imageName = guid.ToString() + ".jpg";

                        if (image.Height > 200 || image.Width > 200)
                        {
                            Image  smallImage = Class.ImageHelper.ScaleImage(image, 200, 200);
                            Bitmap b          = new Bitmap(smallImage);



                            b.Save(Server.MapPath("~/uploads/game/" + imageName), ImageFormat.Jpeg);

                            smallImage.Dispose();
                            b.Dispose();
                        }
                        else
                        {
                            picture.SaveAs(Server.MapPath("~/uploads/game/" + picture.FileName));
                        }


                        game.ImageName = imageName;
                    }
                }

                gameDao.Update(game);

                TempData["message-success"] = "Hra" + game.Name + "byla upravena";
            }
            catch (Exception)
            {
                throw;
            }

            return(RedirectToAction("Index", "Games"));
        }
Example #29
0
        public ActionResult DetailDeveloper(int id)
        {
            GameDao gameDao = new GameDao();
            Game    g       = gameDao.GetById(id);

            if (Request.IsAjaxRequest())
            {
                return(PartialView(g));
            }

            return(View(g));
        }
Example #30
0
        public void paymentFailed(int GameID)
        {
            GameDao gameDao = new GameDao(db);
            Game    game    = gameDao.findGame(GameID);

            game.NumberOfWinners++;
            gameDao.save();
            if (getMaxTransactionTime(game.GameID) == 0)   //is this the last payment failure
            {
                RestartGameRule restartRule = new RestartGameRule(game, db);
                //    restartRule.restart();
            }
        }