public async Task <IActionResult> PostVoteforVideo([FromBody] VoteforVideo voteforVideo) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.VoteforVideo.Add(voteforVideo); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (VoteforVideoExists(voteforVideo.VideoId)) { return(new StatusCodeResult(StatusCodes.Status409Conflict)); } else { throw; } } return(CreatedAtAction("GetVoteforVideo", new { id = voteforVideo.VideoId }, voteforVideo)); }
public async Task <IActionResult> PutVoteforVideo([FromRoute] int id, [FromBody] VoteforVideo voteforVideo) { if (id != voteforVideo.VideoId) { return(BadRequest()); } _context.Entry(voteforVideo).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!VoteforVideoExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }