title: How to write an if statement to check if there is a Applicant ID associated with a User ID in .NET Entity Framevwork MVC
body: <p>I've managed to set up a method in my Account Controller that takes the id associated with a users login and pushes it to my Get_Profile method in another controller. </p>
  
  <pre><code>public ActionResult CheckProfile()
      {
          string userId = User.Identity.GetUserId();
          return RedirectToAction("GetNAA_Profile2", new { UserId = userId, Controller = "NAAProfile" });
      }
  </code></pre>
  
  <p>The GetNAA_Profile2 method is defined like this within the DAO section of the Data layer.</p>
  
  <pre><code>public NAA_Profile GetNAA_Profile2(string UserId)
      {
          IQueryable&lt;NAA_Profile&gt; _profiles;
          _profiles = from profile
                          in _context.NAA_Profile
                      where profile.UserId == UserId
                      select profile;
  
  
          return _profiles.ToList&lt;NAA_Profile&gt;().First();
  
      }
  </code></pre>
  
  <p>It pulls up the associating profile matching up with the UserId from the Profile table in a database I have set up in a database. </p>
  
  <pre><code>CREATE TABLE [b].[NAA_Profile] (
  [ApplicantId]      INT            IDENTITY (1, 1) NOT NULL,
  [ApplicantName]    NVARCHAR (50)  NOT NULL,
  [ApplicantAddress] NVARCHAR (50)  NOT NULL,
  [Phone]            NVARCHAR (50)  NOT NULL,
  [UserId]           NVARCHAR (128) NULL,
  PRIMARY KEY CLUSTERED ([ApplicantId] ASC)
  </code></pre>
  
  <p>);</p>
  
  <p>The method is then finally executed in the Profile controller returning a view with the passed UserId. </p>
  
  <pre><code> public ActionResult GetNAA_Profile2(string UserId)
      {
          return View(_NAAService.GetNAA_Profile2(UserId));
      }
  </code></pre>
  
  <p>My main question is how can I implement an if statement in my method to check if there is a profile associated with the UserId and then redirect the user to another method if there isn't any matching rows. </p>