Beispiel #1
0
        public void AddGame(GameBL element)
        {
            List <Player> players = Mapper.Map <List <Player> >(element.Players);
            Stadium       place   = Mapper.Map <Stadium>(element.Place);

            Game game = new Game()
            {
                Players    = players,
                Place      = place,
                Spectators = element.Spectators,
                Date       = element.Date,
                GameResult = (DataAccessLayer.Entities.Result)element.GameResult
            };

            DB.Games.Create(game);
            DB.Save();
        }
Beispiel #2
0
        public void UpdateGame(GameBL element)
        {
            Game toUpdate = DB.Games.Read(element.Id);

            List <Player> list = new List <Player>();

            foreach (PlayerBL model in element.Players)
            {
                list.Add(DB.Players.Read(model.Id));
            }

            if (toUpdate != null)
            {
                toUpdate.Players    = list;
                toUpdate.Place      = DB.Stadiums.Read(element.Id);
                toUpdate.Spectators = element.Spectators;
                toUpdate.Date       = element.Date;
                toUpdate.GameResult = toUpdate.GameResult;

                DB.Games.Update(toUpdate);
                DB.Save();
            }
        }