Esempio n. 1
0
        public virtual void Update(T obj)
        {
            table.Attach(obj);
            _context.Entry(obj).State = EntityState.Modified;

            this.Save();
        }
Esempio n. 2
0
        public async Task <Team> EditTeamAsync(Team team)
        {
            Team currentTeam = await GetTeamAsync(team.TeamId);

            if (currentTeam == null)
            {
                throw new ArgumentNullException(TeamsExceptionMessage.NoTeam);
            }

            try
            {
                _context.Entry(currentTeam).CurrentValues.SetValues(team);
                await _context.SaveChangesAsync();

                return(team);
            }
            catch (GlobalException)
            {
                throw new GlobalException(GlobalExceptionMessage.GlobalErrorMessage);
            }
        }
        public async Task <Match> EditMatchAsync(Match match)
        {
            Match currentMatch = await GetMatchAsync(match.MatchId);

            if (currentMatch == null)
            {
                throw new ArgumentNullException(MatchesExceptionMessage.NoMatch);
            }

            await _teamServices.CheckIfTeamExcist(match);

            try
            {
                _context.Entry(currentMatch).CurrentValues.SetValues(match);
                await _context.SaveChangesAsync();

                return(match);
            }
            catch (GlobalException)
            {
                throw new GlobalException(GlobalExceptionMessage.GlobalErrorMessage);
            }
        }