Exemplo n.º 1
0
 public HttpResponseMessage UpdateVotes(IncidentVotesRequest model)
 {
     try
     {
         if (ModelState.IsValid)
         {
             var resp = new SuccessResponse();
             _incidentService.Votes(model);
             return(Request.CreateResponse(HttpStatusCode.OK, resp));
         }
         else
         {
             return(Request.CreateResponse(HttpStatusCode.BadRequest, ModelState));
         }
     }
     catch (Exception ex)
     {
         return(Request.CreateResponse(HttpStatusCode.BadRequest, ex));
     }
 }
Exemplo n.º 2
0
        public void Votes(IncidentVotesRequest incidentVotesRequest)
        {
            var upvotes   = SqlInt32.Null;
            var downvotes = SqlInt32.Null;

            if (incidentVotesRequest.Upvotes > 0)
            {
                upvotes = incidentVotesRequest.Upvotes;
            }
            if (incidentVotesRequest.Downvotes > 0)
            {
                downvotes = incidentVotesRequest.Downvotes;
            }

            _dataProvider.ExecuteNonQuery(
                "incidents_votes",
                inputParamMapper : delegate(SqlParameterCollection paramCol)
            {
                paramCol.AddWithValue("@Id", incidentVotesRequest.Id);
                paramCol.AddWithValue("@Upvotes", upvotes);
                paramCol.AddWithValue("@Downvotes", downvotes);
            }
                );
        }