示例#1
0
        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);
        }
示例#2
0
 /// <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());
     }
 }