Example #1
0
 public void UpdatePlayer(Player player)
 {
     using (var context = new FiflackDbContext())
     {
         var playerDb = _mapper.Map <PlayerDb>(player);
         context.Entry(playerDb).State = EntityState.Modified;
         context.SaveChanges();
     }
 }
Example #2
0
 public void AddPlayer(Player player)
 {
     using (var context = new FiflackDbContext())
     {
         var playerDb = _mapper.Map <PlayerDb>(player);
         context.Players.Add(playerDb);
         context.SaveChanges();
     }
 }
Example #3
0
        public void DeletePlayer(int id)
        {
            using (var context = new FiflackDbContext())
            {
                var playerDb = context.Players.FirstOrDefault(x => x.Id == id);

                if (playerDb != null)
                {
                    context.Players.Remove(playerDb);
                    context.SaveChanges();
                }
            }
        }
        public void AddCompetitionMatchScore(int competitionId, MatchScore matchScore)
        {
            using (var context = new FiflackDbContext())
            {
                var matchScoreDb    = _mapper.Map <MatchScoreDb>(matchScore);
                var savedMatchScore = context.MatchScores.Add(matchScoreDb);
                var copmetition     = context.Competitions.FirstOrDefault(x => x.Id == competitionId);

                var competitionMatch = new CompetitionMatchDb();
                competitionMatch.Match       = savedMatchScore;
                competitionMatch.Competition = copmetition;
                context.CompetitionMatches.Add(competitionMatch);

                context.SaveChanges();
            }
        }