public IActionResult AddSportTournamentCountry([FromBody] SportTournament sportTournament) { try { if (sportTournament == null) { return(StatusCode(400, StatusCodes.ReturnStatusObject("No items have been provided."))); } var result = _tournamentRepository.AddSportTournamentCountry(sportTournament); if (result) { _logger.LogInformation("Tournament Successfully Added"); return(StatusCode(200, StatusCodes.ReturnStatusObject("Successfully Added."))); } else { _logger.LogError("Tournament has Failed to Add. Tournament - {0}", sportTournament); return(StatusCode(400, StatusCodes.ReturnStatusObject("Tournament mapping failed to add."))); } } catch (Exception e) { _logger.LogError("Error Tournament failed to add . Error - {0} , Data - {1}", e.Message, sportTournament); return(StatusCode(400, StatusCodes.ReturnStatusObject("Error Tournament mapping Failed to Add."))); } }
public bool AddSportTournamentCountry(SportTournament sportTournament) { using (var connection = DatabaseService.SqlConnection()) { var parameters = new { sportTournament.SportId, sportTournament.TournamentId, sportTournament.CountryId }; var result = connection.Execute("sp_AddSportCountry", parameters, commandType: CommandType.StoredProcedure); return(result < 0); } }
public int Add(SportTournament entity) { int rowAffected = 0; using (var connection = DbService.sqlConnection()) { if (connection.State == ConnectionState.Closed) { connection.Open(); } DynamicParameters parameters = new DynamicParameters(); parameters.Add("@SportId", entity.SportId); parameters.Add("@CountryId", entity.CountryId); parameters.Add("@TournamentId", entity.TournamentId); rowAffected = connection.Execute("AddSportTournament", parameters, commandType: CommandType.StoredProcedure); } return(rowAffected); }
public int Update(SportTournament entity) { throw new NotImplementedException(); }
public int Put([FromBody] SportTournament sportTournament) { return(_sportTournament.Update(sportTournament)); }
public int Post([FromBody] SportTournament sportTournament) { return(_sportTournament.Add(sportTournament)); }