Exemplo n.º 1
0
        public PlayersModel UpdatePlayer(PlayersModel player)
        {
            PlayersModel players = new PlayersModel();

            using (ChallengeEntities challengeEntities = new ChallengeEntities())
            {
                var playersData = challengeEntities.Players.Where(x => x.id == player.ID).FirstOrDefault();
                playersData = JsonConvert.DeserializeObject <Player>(JsonConvert.SerializeObject(player));
                challengeEntities.SaveChanges();
                players = JsonConvert.DeserializeObject <PlayersModel>(JsonConvert.SerializeObject(playersData));
            }

            return(players);
        }
Exemplo n.º 2
0
        public MemberModel AddMember(MemberModel member)
        {
            MemberModel memberModel = new MemberModel();

            using (ChallengeEntities challengeEntities = new ChallengeEntities())
            {
                var memberModelData = JsonConvert.DeserializeObject <Member>(JsonConvert.SerializeObject(member));
                challengeEntities.Members.Add(memberModelData);
                challengeEntities.SaveChanges();
                memberModel = JsonConvert.DeserializeObject <MemberModel>(JsonConvert.SerializeObject(memberModelData));
            }

            return(memberModel);
        }
Exemplo n.º 3
0
        public PlayersModel AddPlayer(PlayersModel player)
        {
            PlayersModel players = new PlayersModel();

            using (ChallengeEntities challengeEntities = new ChallengeEntities())
            {
                var playersModelData = JsonConvert.DeserializeObject <Player>(JsonConvert.SerializeObject(player));
                challengeEntities.Players.Add(playersModelData);
                challengeEntities.SaveChanges();
                players = JsonConvert.DeserializeObject <PlayersModel>(JsonConvert.SerializeObject(playersModelData));
            }

            return(players);
        }
Exemplo n.º 4
0
        public SeriesModel UpdateSeries(SeriesModel series)
        {
            SeriesModel seriesModel = new SeriesModel();

            using (ChallengeEntities challengeEntities = new ChallengeEntities())
            {
                var seriesData = challengeEntities.Series.Where(x => x.id == series.ID).FirstOrDefault();
                seriesData = JsonConvert.DeserializeObject <Series>(JsonConvert.SerializeObject(seriesData));
                challengeEntities.SaveChanges();
                series = JsonConvert.DeserializeObject <SeriesModel>(JsonConvert.SerializeObject(seriesData));
            }

            return(series);
        }
Exemplo n.º 5
0
        public SeriesModel AddSeries(SeriesModel series)
        {
            SeriesModel seriesModel = new SeriesModel();

            using (ChallengeEntities challengeEntities = new ChallengeEntities())
            {
                var seriesModelData = JsonConvert.DeserializeObject <Series>(JsonConvert.SerializeObject(series));
                challengeEntities.Series.Add(seriesModelData);
                challengeEntities.SaveChanges();
                seriesModel = JsonConvert.DeserializeObject <SeriesModel>(JsonConvert.SerializeObject(seriesModelData));
            }

            return(seriesModel);
        }
Exemplo n.º 6
0
        public PlayersModel GetPlayerById(int PlayerId)
        {
            PlayersModel players = new PlayersModel();

            using (ChallengeEntities challengeEntities = new ChallengeEntities())
            {
                var playersData = (from pl in challengeEntities.Players
                                   join n in challengeEntities.Nationalities on pl.Nationality equals n.id
                                   where pl.id == PlayerId
                                   select new { pl, n }).ToList();
                if (playersData != null && playersData.Count > 0)
                {
                    foreach (var eachRow in playersData)
                    {
                        players             = JsonConvert.DeserializeObject <PlayersModel>(JsonConvert.SerializeObject(eachRow.pl));
                        players.nationality = JsonConvert.DeserializeObject <NationalityModel>(JsonConvert.SerializeObject(eachRow.n));
                    }
                }
            }
            return(players);
        }
Exemplo n.º 7
0
        public List <PlayersModel> GetPlayerByNationId()
        {
            List <PlayersModel> players           = new List <PlayersModel>();
            ChallengeEntities   challengeEntities = new ChallengeEntities();

            var playersData = (from pl in challengeEntities.Players
                               join n in challengeEntities.Nationalities on pl.Nationality equals n.id
                               where pl.Nationality == nationId
                               select new { pl, n }).ToList();

            if (playersData != null && playersData.Count > 0)
            {
                foreach (var eachRow in playersData)
                {
                    PlayersModel p = new PlayersModel();
                    p             = JsonConvert.DeserializeObject <PlayersModel>(JsonConvert.SerializeObject(eachRow.pl));
                    p.nationality = JsonConvert.DeserializeObject <NationalityModel>(JsonConvert.SerializeObject(eachRow.n));
                    players.Add(p);
                }
            }
            return(players);
        }