public async Task <Models.Database.VoteCandidate> UpdateCandidate(Models.Database.VoteCandidate voteCandidate) { using (var context = new toafcContext()) { context.VoteCandidates.Update(voteCandidate); await context.SaveChangesAsync(); } return(voteCandidate); }
public async Task <Models.Database.VoteCandidate> UpdateCandidate(Models.Database.VoteCandidate candidate) { Exceptions.TestForNull(candidate, nameof(candidate)); candidate = await voteCandidateDB.UpdateCandidate(candidate); var cacheKey = "VoteCandidates"; _cacheOperation.Delete(cacheKey); return(candidate); }
public async Task <IActionResult> UpdateCandidate([FromBody] Models.Database.VoteCandidate candidate) { try { return(Json(await voteCandidate.UpdateCandidate(candidate))); } catch (Exception e) { return(StatusCode(500, e)); } }