Ejemplo n.º 1
0
        public ActionResult AddGame()
        {
            GameViewModel gvm     = new GameViewModel();
            Game          objGame = new Game();

            if (Request.Form["game.name"] == null)
            {
                return(View("AddGame", gvm));
            }
            objGame.name      = Request.Form["game.name"].ToString();
            objGame.console   = Request.Form["game.console"].ToString();
            objGame.genre     = Request.Form["game.genre"].ToString();
            objGame.price     = Request.Form["game.price"].ToString();
            objGame.coverLink = Request.Form["game.coverLink"].ToString();
            objGame.stock     = Request.Form["game.stock"].ToString();
            GameDal dal = new GameDal();

            //data validation before updating db
            if (ModelState.IsValid)
            {
                dal.Games.Add(objGame);
                dal.SaveChanges();
                gvm.game = new Game();
            }
            else
            {
                gvm.game = objGame;
            }

            gvm.games = dal.Games.ToList <Game>();
            return(View("AddGame", gvm));
        }
Ejemplo n.º 2
0
        // GET: Shop
        public ActionResult ShopHomePage()
        {
            //reset sum if nothing in cart
            if (Global.sum == 0)
            {
                Session["sum"] = "0";
            }

            //if has cookies remembers user
            HttpCookie cookie    = Request.Cookies["Name"];
            HttpCookie percookie = Request.Cookies["permission"];

            if (cookie != null)//case has cookies
            {
                //saves user name and permission to display current information
                Session["userName"] = Request.Cookies["Name"].Value;
                if (percookie != null)
                {
                    Session["permission"] = Request.Cookies["permission"].Value;
                }
            }

            //gets the current cart
            Session["cart"] = Global.cart;

            //game view model display all games
            GameDal       dal      = new GameDal();
            List <Game>   objGames = dal.Games.ToList <Game>();
            GameViewModel gvm      = new GameViewModel();

            gvm.game  = new Game();
            gvm.games = objGames;
            return(View(gvm));
        }
Ejemplo n.º 3
0
        public ActionResult Orders()
        {
            //display to admin all orders made
            GameDal dal = new GameDal();
            Game    o   = new Game();

            return(View());
        }
Ejemplo n.º 4
0
        public ActionResult Game(string name)
        {
            //display a game onto the user when selecting order now
            GameDal dal = new GameDal();
            Game    g   = new Game();

            g = dal.findGame(name);
            return(View(g));
        }
Ejemplo n.º 5
0
 /// <summary>
 /// gameroom constructor
 /// </summary>
 public GameRoom(User host, string gameName)
 {
     ValidateName(gameName);
     this._host     = host.username;
     this._gameName = gameName;
     _status        = GameStatus.Starting;
     GameID         = GameDal.AddGame(gameName, this._host, (int)status);
     game           = new Game(this);
 }
Ejemplo n.º 6
0
        /// <summary>
        /// returns a list of how many days were played in the last 30 days, where index 0 is today and 29 is 29 days ago
        /// </summary>
        public static List <int> GamesPlayedInMonth()
        {
            List <int> Games = new List <int>();

            for (int i = 0; i < 30; i++)
            {
                DateTime today    = DateTime.Today.Subtract(TimeSpan.FromDays(i));
                DateTime tommorow = today.AddDays(1);
                Games.Add(GameDal.GamesPlayedBetweenDates(today, tommorow));
            }
            return(Games);
        }
Ejemplo n.º 7
0
        public ActionResult addToCart(string name)
        {
            //game dal refrense to add a game to cart
            GameDal dal = new GameDal();
            Game    g   = new Game();

            //find game by game name
            g = dal.findGame(name);

            //adds the found game to cart
            Global.cart.Add(g);
            //updates sum
            Global.sum    += Int32.Parse(g.price);
            Session["sum"] = Global.sum.ToString();

            //shows current cart
            return(View("viewcart"));
        }
Ejemplo n.º 8
0
        public ActionResult Search()
        {
            GameDal dal           = new GameDal();
            string  searchName    = "";
            string  searchConsole = "";

            if (Request.Form["txtName"] != null)
            {
                searchName = Request.Form["txtName"].ToString();
            }
            if (Request.Form["ddConsole"] != null)
            {
                searchConsole = Request.Form["ddConsole"].ToString();
            }
            //Searching by passed criteria
            List <Game> objGames =
                (from x in dal.Games
                 where x.name.Contains(searchName) where x.console.Contains(searchConsole)
                 select x).ToList();
            GameViewModel gvm = new GameViewModel();

            gvm.games = objGames;
            return(View(gvm));
        }
Ejemplo n.º 9
0
        public ActionResult checkOut()
        {
            //updates stock
            GameDal       dal = new GameDal();
            GameViewModel gvm = new GameViewModel();

            gvm.games = new List <Game>();


            //create game view model
            foreach (Game g in dal.Games)
            {
                gvm.games.Add(g);
            }

            //updates the stock for each game purchesed
            for (int j = 0; j < Global.cart.Count(); j++)
            {
                for (int i = 0; i < gvm.games.Count(); i++)
                {
                    if (gvm.games[i].name == Global.cart[j].name)
                    {
                        if (Int32.Parse(gvm.games[i].stock) == 0)
                        {
                            gvm.games[i].stock = "0";
                        }
                        else
                        {
                            gvm.games[i].stock = (Int32.Parse(gvm.games[i].stock) - 1).ToString();
                        }

                        break;
                    }
                }
            }
            //saves the updates
            dal.SaveChanges();

            //addes a new order
            OrderDal odal  = new OrderDal();
            string   uname = Session["userName"].ToString();
            Order    or    = new Order();

            or.userName = uname;
            int sum = Int32.Parse(Session["sum"].ToString());

            or.sum = sum;

            odal.orders.Add(or);
            odal.SaveChanges();
            Order o = odal.getLastOrder();


            //connect all cart items to the above order
            ItemsDal idal = new ItemsDal();

            foreach (Game g in Global.cart)
            {
                idal.items.Add(new Item(o.id, g.name));
            }
            idal.SaveChanges();

            //resets cart and global variables
            Global.cart    = new List <Game>();
            Global.sum     = 0;
            Session["sum"] = "0";

            //retuns thank you for your purchese
            return(View());
        }
Ejemplo n.º 10
0
 private GameBll()
 {
     gameDal   = GameDal.Instance();
     arenaDal  = ArenaDal.Instance();
     playerDal = PlayerDal.Instance();
 }
Ejemplo n.º 11
0
        static void Main(string[] args)
        {
            Console.WriteLine("FIFA player işlemeleri");
            Gamer fifaGamer = new Gamer()
            {
                FirstName     = "fifaGamerManager Gamer FirstName",
                LastName      = "fifaGamerManager LastName",
                NationalityId = "01234567890",
                YearOfBirth   = new DateTime(2000, 1, 1)
            };
            FifaGamerManager fifaGamerManager = new FifaGamerManager(new GamerCheckManager());

            fifaGamerManager.Add(fifaGamer);
            Console.WriteLine();
            Console.WriteLine("CSGO player işlemeleri");

            Gamer csgoGamer = new Gamer()
            {
                FirstName     = "csgoGamerManager Gamer FirstName",
                LastName      = "csgoGamerManager LastName",
                NationalityId = "01234567890",
                YearOfBirth   = new DateTime(2000, 1, 1)
            };

            CSGOGamerManager csgoGamerManager = new CSGOGamerManager(new GamerCheckManager());

            csgoGamerManager.Add(csgoGamer);
            Console.WriteLine();
            Console.WriteLine("Game İşlemleri");
            Game csgGame = new Game()
            {
                GameName = "CS Go", GamePrice = 1200
            };
            Game fifaGame = new Game()
            {
                GameName = "Fifa 2020", GamePrice = 1900
            };
            GameDal csgGameDal = new GameDal();

            csgGameDal.Add(csgGame);
            GameDal fifaGameDal = new GameDal();

            fifaGameDal.Add(fifaGame);

            Console.WriteLine();
            Console.WriteLine("Campaign İşlemleri");
            Campaign fifaCampaign = new Campaign()
            {
                CampaignDiscount = 10, CampaignName = "Covid 2020"
            };
            Campaign csgoCampaign = new Campaign()
            {
                CampaignDiscount = 19, CampaignName = "Covid 2021 "
            };
            CampaignDal campaignDal = new CampaignDal();

            campaignDal.Add(fifaCampaign);
            campaignDal.Add(csgoCampaign);

            ISalesService salesService = new SalesManager();

            salesService.CampaignSale(fifaGame, fifaGamer, fifaCampaign);
            salesService.CampaignSale(csgGame, csgoGamer, csgoCampaign);
        }
Ejemplo n.º 12
0
 /// <summary>
 /// a methods which finds and returns a list of all game rooms with starting status which their name contain the search term
 /// </summary>
 public static List <GameRoom> SearchStartingGameRoom(string searchTerm)
 {
     return(GameRoomTableToGameRoomList(GameDal.SearchGame(searchTerm, (int)GameStatus.Starting)));
 }
Ejemplo n.º 13
0
        /// <summary>
        /// updates the game room information
        /// </summary>
        public void UpdateRoom()
        {
            DataRow dr = GameDal.FindGameByID(GameID);

            UpdateRoom(dr);
        }
Ejemplo n.º 14
0
 public GameController(GameDal gameDal)
 {
     _gameDal = gameDal;
 }