title: How to convert integer to boolean in C#
body: <p>I have stored procedure that returns:</p>
  
  <ul>
  <li><strong>0</strong> - no user no app no role in the tables</li>
  <li><strong>1</strong> - true, there is user, role, app that u require</li>
  <li><strong>2</strong> - there is no user with that name = false</li>
  <li><strong>3</strong> - there is no role with that name = false</li>
  </ul>
  
  <p>When I call the Stored Procedure in the C# I get : </p>
  
  <blockquote>
    <p>Cannot implicitly convert type 'bool' to 'int'</p>
  </blockquote>
  
  <pre><code>public int IsUserInRole(IsUserInRole userInRole)
  {
      var model =  _userRepository.CheckIfUserIsInRole(userInRole);
      if (model == 1)
      {
          return true;
      }
      else
      {
          return false;
      }
  }
  </code></pre>
  
  <p>I need to use this to validate the logged User in what role is assign so I can Authorize later based on the <code>UserRole</code>.</p>
  
  <p>So I need true or false from the SP, that mean that I need to Convert Integer to Boolean</p>
  
  <p>I have try <a href="https://stackoverflow.com/questions/15108738/better-way-to-convert-an-int-to-a-boolean">Better way to convert an int to a boolean</a>
  and <a href="http://www.dotnetperls.com/convert-bool-int" rel="nofollow noreferrer">http://www.dotnetperls.com/convert-bool-int</a> but no luck for me there :).</p>
  
  <p>Any advice how to solve this problem?</p>