Beispiel #1
0
        public async Task Save(int id, MatchOddDto matchOddDto)
        {
            if (id != matchOddDto.Id)
            {
                throw new ArgumentException("Invalid id");
            }

            var matchOdd = _mapper.Map <MatchOdd>(matchOddDto);

            _modelValidators.ThrowIfInvalid(matchOdd);

            _context.Entry(matchOdd).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException ex)
            {
                if (!Exists(id))
                {
                    throw new ApplicationException("Key does not exists");
                }
                else
                {
                    throw new ApplicationException(ex.Message);
                }
            }
        }