public CastVoteDetailsResponse CastVote(CastVoteDetailsRequest request) { var response = new CastVoteDetailsResponse(); Guid userId; if (!Guid.TryParse(request.Vote.UserId, out userId)) { response.AddError(new Error { Code = ErrorCodes.InvalidGuidProvided, UserMessage = "Something went wrong. Please try again later.", TechnicalMessage = "Provided user identifier is not a valid guid." }); return(response); } Guid dealId; if (!Guid.TryParse(request.Vote.DealId, out dealId)) { response.AddError(new Error { Code = ErrorCodes.InvalidGuidProvided, UserMessage = "Something went wrong. Please try again later.", TechnicalMessage = "Provided deal identifier is not a valid guid." }); return(response); } var castVoteResponse = _voteRepository.CastVote(new CastVoteRequest { UserId = userId, DealId = dealId, Positive = request.Positive }); if (castVoteResponse.HasError) { response.AddError(castVoteResponse.Error); } return(response); }
public IActionResult PostVote(Vote vote) { try { _log4net.Info("Vote Getting Added - " + "Vote Id is " + (vote.VoteID + 1).ToString()); if (ModelState.IsValid) { var added = _voterRepo.CastVote(vote); return(CreatedAtAction(nameof(PostVote), new { id = vote.VoteID }, vote)); } return(BadRequest()); } catch { _log4net.Error("Error in Adding Vote"); return(new NoContentResult()); } }
public IActionResult Add(Vote vote) { try { _log4net.Info("Vote Getting Added - " + "Vote Id is " + (vote.VoteID + 1).ToString()); var added = _voterRepo.CastVote(vote); if (added) { return(StatusCode(201)); } else { return(new NoContentResult()); } } catch { _log4net.Error("Error in Adding Vote"); return(new NoContentResult()); } }
public void Post(int userId, String ideaId, bool voted) { VoteRepository.CastVote(userId, ideaId, voted); }