public Match Add(Match match) { DbMatch dbMatch = DbMatch.FromModel(match); dbMatch = _context.Matches .Add(dbMatch) .Entity; try { _context.SaveChanges(); } catch (DbUpdateException) { throw new ArgumentException("Unable to create Match with such data!"); } return(dbMatch.ToModel()); }
public Match Update(Match match) { DbMatch dbMatch = _context.Matches .SingleOrDefault(m => m.Id == match.Id) ?? throw new ArgumentException($"No natch with id {match.Id}!"); dbMatch.Status = match.Status; dbMatch = _context.Matches .Update(dbMatch) .Entity; try { _context.SaveChanges(); } catch (DbUpdateException) { throw new ArgumentException("Unable to create summary suggestions with such data!"); } return(dbMatch.ToModel()); }