Example #1
0
 public IHttpActionResult GetbyUser([FromUri] int UserId)
 {
     if ((new[] { "Admin", "User" }).Contains(ValidateTokenAndRole.ValidateAndGetRole(Request), StringComparer.OrdinalIgnoreCase))
     {
         IEnumerable <VoteModel> List = repo.GetAllbyUserId(UserId).Select(Vote => Vote?.ToModel());
         if (List.Count() == 0)
         {
             return(NotFound());
         }
         else
         {
             return(Json(List));
         }
     }
     else
     {
         return(Unauthorized());
     }
 }