title: How to get id based on username and password using Web API and Xamarin forms
body: <p>I need to get only from table based on username and password.</p>
  
  <p>I am using Xamarin cross-platform, and Web API to connect to SQL Server.</p>
  
  <p>Here is my code:</p>
  
  <p><strong>Web Api - Controller</strong></p>
  
  <pre><code>[HttpGet]
  [ActionName("XAMARIN_Login")]      
  public IHttpActionResult GetId(string username, string password)
  {
      var result = db.AspNetUsers
          .Where(x =&gt; x.UserName == username &amp;&amp; x.PasswordHash == password)
          .Select(x =&gt; x.Id)
          .FirstOrDefault();
      return Ok(result);
  }
  </code></pre>
  
  <p><strong>Xamarin - RestClient.cs</strong></p>
  
  <pre><code>private const string WebloginUrl = "http://172.16.4.212:55364/api/AspNetUsers/GetId/";
  
  public async Task&lt;List&lt;T&gt;&gt; checkLogin(string username, string password)
  {
      var httpClient = new HttpClient();
      var json = await httpClient.GetStringAsync(
          WebloginUrl + "?username=" + username + "&amp;" + "password=" + password);
  
      var taskModels = JsonConvert.DeserializeObject&lt;List&lt;T&gt;&gt;(json);
      return taskModels;
  }
  </code></pre>
  
  <p><strong>Xamarin - Services.cs</strong></p>
  
  <pre><code>public async Task&lt;List&lt;UserDetail&gt;&gt; GetId(string username, string password)
  {
      RestClient&lt;UserDetail&gt; userDetail = new RestClient&lt;UserDetail&gt;();
      var user = await userDetail.checkLogin(username, password);
      return user;
  }
  </code></pre>
  
  <p><strong>Xamarin - MainPage.xaml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
               xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
               xmlns:local="clr-namespace:Employee"
               xmlns:ViewModels="clr-namespace:Employee.ViewModels"
               x:Class="Employee.MainPage" Title="Kulsum International Hospital"&gt;
      &lt;StackLayout&gt;
          &lt;Entry x:Name="EntryUsername" /&gt;
          &lt;Entry x:Name="EntryPassword" /&gt;
          &lt;Entry x:Name="Id" /&gt; 
  
          &lt;!-- what I want when user click on button Id should appear in this entry --&gt;
          &lt;Button x:Name="ButtonLogin" Clicked="ButtonLogin_Clicked" /&gt;
      &lt;/StackLayout&gt;
  &lt;/ContentPage&gt;
  </code></pre>
  
  <p><strong>Xamarin - MainPage.xaml.cs</strong></p>
  
  <pre><code>private async void ButtonLogin_Clicked(object sender, EventArgs e)
  {
      EmployeesServices services = new EmployeesServices();
      var getLoginDetails = await services.GetId(EntryUsername.Text, EntryPassword.Text);
      // Here I don't know what to do to get id in entry
  }
  </code></pre>
  
  <p>I have uploaded all my code now. This code working absolutely fine, but I am just confused on the last step. I don't know how to show the id in entry when a user clicks on the button.</p>