title: Bool value cannot be changed
body: <p>I am tying to deactivate the user automatically once the expiry date is over. So while viewing the user account details, the account of the users who crossed Expiry Date should be shown as inactive (Using fa-toggle on/off - to show active/inactive status of account - in code it is a bool value true/false). </p>
  
  <p><strong>Existing:</strong></p>
  
  <ol>
  <li>While clicking on get account details, </li>
  <li>Details will be extracted from DB displayed, </li>
  <li>As extracted it will be displayed in the application</li>
  </ol>
  
  <p><strong>What I did is ?</strong></p>
  
  <ol>
  <li>While clicking on get account details, </li>
  <li>Details will be extracted from DB displayed,</li>
  <li>Before displaying to the end user, </li>
  <li>I am trying to change the active/inactive details of the customer, by comparing current date with expiry date.</li>
  <li>As extracted it will be displayed in the application</li>
  </ol>
  
  <p><strong>Existing Code:</strong></p>
  
  <pre><code>public IEnumerable&lt;CustomerDetails&gt; GetCustomerDetails(string groupName)
  {
      IEnumerable&lt;CustomerDetails&gt; customers;
  
      var query = "select up.username, up.firstname, up.lastname, up.lastactivitydate, up.expirydate, " +
                              "up.activationdate, up.licensedby, up.position, up.isactive as isActiveUser, " +
                              "wr.rolename, up.usergroup, ul.contracttype as contracttype, ul.numberoflicense as " +
                              "licensesallowed from userprofile up inner join userlicense ul on ul.id = up.firmid inner join " +
                              "webpages_UsersInRoles wur on wur.userid =  up.userid inner join webpages_Roles wr on " +
                              "wr.roleid = wur.roleid where ul.firmname='" + firmname.Replace("'", "''") + "' order by up.lastname";
  
      using (IDbConnection dbConnection = new SqlConnection(UserDBConnectionString))
      {
          dbConnection.Open();
  
          using (var result = dbConnection.QueryMultiple(query, commandTimeout: 300))
          {
              var accounts = result.Read().ToList();
  
              customers = from account in accounts
                                           select new CustomerDetails
                                           {
                                               FirstName = account.firstname,
                                               LastName = account.lastname,
                                               UserName = account.username,
                                               PreviousUserName = account.username,
                                               Position = account.position,
  
                                               SharedSpace = JsonConvert.DeserializeObject&lt;string[]&gt;(account.usergroup),
  
                                               UserRole = account.rolename,
                                               IsActiveUser = account.isActiveUser,
  
                                               LastActivityDate = account.lastactivitydate != null
                                               ? account.lastactivitydate.ToString("yyyy/MM/dd")
                                               : "",
  
                                               ExpiryDate = TimeZoneInfo.ConvertTimeToUtc((DateTime)account.expirydate),
  
                                               ActivationDate = TimeZoneInfo.ConvertTimeToUtc((DateTime)account.activationdate),
  
                                               ContractType = account.contracttype.ToString().Trim(),
  
                                               LicensesAllowed = account.licensesallowed
                                           };
          }
      }
      return customers;
  }
  </code></pre>
  
  <p>The thing I did is before returning customers details, <code>return customers;</code>. I have included the following set of code to deactivate the users who all crossed the activation period. But it is not working as expected. </p>
  
  <pre><code>// code as above shown
  var count = customers.Count();
  for (var i = 0; i &lt; count;i++)
  {
      DateTime dateLimit = Convert.ToDateTime(customers.ElementAt(i).ExpiryDate); 
      DateTime currentDate = DateTime.Now.Date;
      int result = DateTime.Compare(dateLimit,currentDate);
      if (result == -1)
      {
          if (customers.ElementAt(i).IsActiveUser == true)
          {
              var beforeChanged = customers.ElementAt(i).IsActiveUser; // before it is true
  
              customers.ElementAt(i).IsActiveUser = false; // i hope i am setting the value as false
  
              var afterChanged = customers.ElementAt(i).IsActiveUser; // but i am still seeing true only here               
  
          }                    
      }
  }
  return customers
  }
  </code></pre>
  
  <p><strong>Edit -1 :</strong></p>
  
  <p><a href="https://i.stack.imgur.com/bEyXP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bEyXP.png" alt="enter image description here"></a></p>
  
  <p>As I said in comment, I can able to change the value here from true to false vice versa. </p>
  
  <p><strong>Edit -2 :</strong></p>
  
  <p>// customer class structure</p>
  
  <pre><code>public class CustomerDetails
  {
      public string FirstName { get; set; }
  
      public string LastName { get; set; }
  
      public bool IsActiveUser { get; set; }
      // some other fields ... goes here
  }
  </code></pre>
  
  <p>I don't know how it still be true after setting the value as false. </p>