public bool Create(VoteDTO user) { bool b1 = ur.Create(Mapper.Map <VoteEntity>(user)); if (b1) { if (user.vote == true) { ar.IncrementVotes(user.answerId); } else { ar.DecrementVotes(user.answerId); } } return(b1); }
/// <summary> /// Post API/Vote /// </summary> /// <param name="E">Vote à insérer</param> public IHttpActionResult Post(VoteModel Vote) { if ((new[] { "Admin", "User" }).Contains(ValidateTokenAndRole.ValidateAndGetRole(Request), StringComparer.OrdinalIgnoreCase)) { if (Vote == null || Vote.Strategy.Id == 0 || Vote.User.Id == 0) { return(BadRequest()); } else { repo.Create(Vote.ToEntity()); return(Ok()); } } else { return(Unauthorized()); } }