public async Task <int> AddCurrencyAsync(CurrencyAddModel currency) { string query = $@"INSERT INTO Currency (Code,Symbole) OUTPUT INSERTED.CurrencyId VALUES(@Code,@Symbole)"; return(await GetSingleDataAsync <int>(query, currency)); }
public async Task <int> AddCurrency(CurrencyAddModel currency) { var validator = DataValidatorHelper.Validate(currency); if (validator.IsValid) { var currencyDb = await _gamedbAccess.GetCurrencyByCodeAsync(currency.Code); if (currencyDb == null) { return(await _gamedbAccess.AddCurrencyAsync(currency)); } return(currencyDb.CurrencyId); } Console.WriteLine($"Invalid Data from {nameof(CurrencyAddModel)}"); validator.Errors.ForEach(e => Console.WriteLine(e)); throw new Exception("Some data are invalid"); }