Beispiel #1
0
        /// <summary>
        /// Save a Game to the Database
        /// </summary>
        /// <param name="game">Gameobject to Save</param>
        /// <returns>1 if successfull, otherwise 0</returns>
        public int SaveGame(FluffTailRanking.BusinessLayer.BusinessObjects.Game game)
        {
            try
            {
                using (KickerEntities context = new KickerEntities())
                {
                    FluffTailRanking.BusinessLayer.Persistence.Game current = new FluffTailRanking.BusinessLayer.Persistence.Game()
                    {
                        date    = DateTime.Now,
                        teamone = game.Team1.ID,
                        teamtwo = game.Team2.ID,
                        winner  = game.Winner.ID
                    };

                    //TODO: Update Player wins / losts on save

                    context.Game.Add(current);
                    context.SaveChanges();
                }
                return(1);
            }
            catch (Exception ex)
            {
                return(0);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Get all Games out of the Database
        /// </summary>
        /// <returns>List with all Games</returns>
        public List <FluffTailRanking.BusinessLayer.BusinessObjects.Game> GetAllGames()
        {
            List <FluffTailRanking.BusinessLayer.BusinessObjects.Game> games = new List <FluffTailRanking.BusinessLayer.BusinessObjects.Game>();

            using (KickerEntities contex = new KickerEntities())
            {
                var query =
                    from game in contex.Game
                    select new
                {
                    id     = game.id,
                    date   = game.date,
                    winner = game.winner,
                    t1     = game.teamone,
                    t2     = game.teamtwo
                };

                foreach (var matches in query)
                {
                    FluffTailRanking.BusinessLayer.BusinessObjects.Game game = new FluffTailRanking.BusinessLayer.BusinessObjects.Game()
                    {
                        ID     = matches.id,
                        Team1  = GetTeamById(matches.t1),
                        Team2  = GetTeamById(matches.t2),
                        Date   = matches.date,
                        Winner = GetTeamById(matches.winner)
                    };
                    games.Add(game);
                }
            };

            return(games);
        }
        /// <summary>
        /// Get all Games out of the Database
        /// </summary>
        /// <returns>List with all Games</returns>
        public List<FluffTailRanking.BusinessLayer.BusinessObjects.Game> GetAllGames()
        {
            List<FluffTailRanking.BusinessLayer.BusinessObjects.Game> games = new List<FluffTailRanking.BusinessLayer.BusinessObjects.Game>();
            using (KickerEntities contex = new KickerEntities())
            {
                var query =
                    from game in contex.Game
                    select new
                    {
                        id = game.id,
                        date = game.date,
                        winner = game.winner,
                        t1 = game.teamone,
                        t2 = game.teamtwo
                    };

                foreach (var matches in query)
                {
                    FluffTailRanking.BusinessLayer.BusinessObjects.Game game = new FluffTailRanking.BusinessLayer.BusinessObjects.Game()
                    {
                        ID = matches.id,
                        Team1 = GetTeamById(matches.t1),
                        Team2 = GetTeamById(matches.t2),
                        Date = matches.date,
                        Winner = GetTeamById(matches.winner)
                    };
                    games.Add(game);
                }
            };

            return games;
        }
Beispiel #4
0
 public int AddGame(Game newgame)
 {
     try
     {
         return persistentManager.SaveGame(newgame);
     }
     catch (Exception ex)
     {
         return 0;
     }
 }
 public int SaveGame(Game game)
 {
     throw new NotImplementedException();
 }