title: Call a Task and return True or False MVC 6
body: <p><strong>I can call this task. I can't seem to understand what is returned. Much less use it. I just want a True or False so I can save a Role or not.</strong></p>
  
  <pre><code>   public ActionResult Create([FromServices]IServiceProvider serviceProvider,string roleName)
      {
  
          ModelState.Clear();
  
          try
          {
  
          var doesit= DoesRoleExist(serviceProvider, roleName);
  
              if (string.IsNullOrEmpty(roleName))
              {
                  throw new Exception("Invalid Role Name: Cannot be empty and must be unique");
              }
  
  
  
               context.Roles.Add(new Microsoft.AspNet.Identity.EntityFramework.IdentityRole()
              {
                  Name = roleName,
                  NormalizedName = roleName.ToUpper()
              });
  
              context.SaveChanges();
  
              return RedirectToAction("Index");
          }
          catch
          {
              ModelState.AddModelError(string.Empty, string.Format("{0}", "Unable to Create Role. "));
              return View();
          }
      } 
  </code></pre>
  
  <p><strong>I get this when I break on "var doesit=DoesRoleExist(serviceProvider,roleName)"</strong></p>
  
  <p>?   doesit</p>
  
  <p>Id = 2093, Status = WaitingForActivation, Method = "{null}", Result = "{Not yet computed}"
      AsyncState: null
      CancellationPending: false
      CreationOptions: None
      Exception: null
      Id: 2093
      Result: false
      Status: WaitingForActivation</p>
  
  <p><strong>Here is the Task:</strong></p>
  
  <pre><code> private async Task&lt;bool&gt; DoesRoleExist(IServiceProvider serviceProvider, string roleName)
          {
  
              bool result =false;
  
              var RoleManager = serviceProvider.GetRequiredService&lt;RoleManager&lt;IdentityRole&gt;&gt;();
  
             result = await RoleManager.RoleExistsAsync(roleName);
             return result;
      }
  </code></pre>
  
  <p>It's funny but besides the "can't compare boolean using ===" which I ran into when I put an If statement in the ActionResult, I also see that in the above Task, "return result;" runs AFTER "result=await RoleManager.RoleExistsAsync(roleName);". Go figure. Just a simple true or false is all I ask and the ability to compare a boolean to see if I want to add the Role or not.</p>
  
  <p>I want to add that my context.Roles does not have "RoleExists" method.
  However, for some reason in an async task I can call ".RoleExistsAsync" for some reason. </p>