I am trying to accomplish an auto refresh on an angular component which shows scores of different teams. So when ever the score is updated I need to refresh the Score in frontend
Based on my previous question here I have found server sent events are helpful for the purpose. But honestly I have got stuck with how to proceed with
Here is my update code in my controller, when which I want to refresh the score as well. Also I have a get function also to just read all the scores
// GET: api/TblVottings
[HttpGet]
public async Task<ActionResult<IEnumerable<TblVotting>>> GetTblVottings()
{
return await _context.TblVottings.ToListAsync();
}
// PUT: api/TblVottings/5
// To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754
[HttpPut("{id}")]
public async Task<IActionResult> PutTblVotting(int id, TblVotting tblVotting)
{
if (id != tblVotting.SessionId)
{
return BadRequest();
}
_context.Entry(tblVotting).State = EntityState.Modified;
try
{
await _context.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
if (!TblVottingExists(id))
{
return NotFound();
}
else
{
throw;
}
}
return NoContent();
}
I have found an answer which give me some hint, but I didnt understand it based on my scenario..
Please suggest how to achieve that..