public void UpdateVotesOfCandidate(GlasoviKandidat votes) { try { string connectionString = ConnectionStringHelper.GetConnectionString(_configuration); using (SqlConnection connection = new SqlConnection(connectionString)) { connection.Open(); using (SqlTransaction transaction = connection.BeginTransaction()) { ExecutorService repository = new ExecutorService(connection, transaction); List <SqlParameter> parameters = new List <SqlParameter>(); repository.AddParameterInList("@Id", votes.id, SqlDbType.BigInt, ref parameters); repository.AddParameterInList("@BrojGlasova", votes.brojGlasova, SqlDbType.Int, ref parameters); SqlDataReader dataReader = repository.ExecuteProcedure(Constants.UPDATE_NUMBER_OF_VOTES_CANDIDATE, parameters); dataReader.Close(); transaction.Commit(); } } } catch (Exception ex) { throw ex; } }
public IActionResult Put([FromBody] GlasoviKandidat votes) { _service.UpdateVotesOfCandidate(votes); return(Ok()); }
public IActionResult GetById([FromQuery] long id) { GlasoviKandidat votes = _service.GetVotesById(id); return(Ok(votes)); }