title: Need to access and edit an attribute in a database
body: <p>Orders are created and saved in this method</p>
  
  <pre><code>public async Task&lt;ActionResult&gt; FirstClassCreate(FormCollection values)
      {
          var order = new Order();
          TryUpdateModel(order);
          var customer = db.Users.FirstOrDefault(x =&gt; x.Email == User.Identity.Name);
          var cart = ShoppingCart.GetCart(this.HttpContext);
  
          try
          {
              order.DeliveryDate = DateTime.Now.AddDays(1);
  
              order.DeliveryMethod = "First Class";
              order.FirstName = customer.FirstName;
              order.LastName = customer.LastName;
              order.PostalCode = customer.PostalCode;
              order.State = customer.State;
              order.City = customer.City;
              order.Email = customer.Email;
              order.Country = customer.Country;
              order.Phone = customer.PhoneNumber;
              order.Address = customer.Address;
              order.HasPaid = false;
              order.Username = customer.Email;
              order.OrderDate = DateTime.Now;
              var currentUserId = User.Identity.GetUserId();
              order.Total = cart.GetFirstClass();
  
              if (order.SaveInfo &amp;&amp; !order.Username.Equals("guest@guest.com"))
              {
                  var manager = new UserManager&lt;ApplicationUser&gt;(new UserStore&lt;ApplicationUser&gt;(new ApplicationDbContext()));
                  var store = new UserStore&lt;ApplicationUser&gt;(new ApplicationDbContext());
                  var ctx = store.Context;
                  var currentUser = manager.FindById(User.Identity.GetUserId());
  
                  //Save this back
                  //http://stackoverflow.com/questions/20444022/updating-user-data-asp-net-identity
                  //var result = await UserManager.UpdateAsync(currentUser);
                  await ctx.SaveChangesAsync();
  
                  await storeDB.SaveChangesAsync();
              }
  
              //Save Order
              storeDB.Orders.Add(order);
              await storeDB.SaveChangesAsync();
  
              //Process the order
              cart = ShoppingCart.GetCart(this.HttpContext);
              order.Total = cart.GetFirstClass();
  
              order = cart.CreateOrder(order);
  
              return RedirectToAction("FirstClass", "Checkouts", order);
          }
          catch
          {
              //Invalid - redisplay with errors
              return View(order);
          }
      }   
  </code></pre>
  
  <p>I need to be access the orders database and change attributes of a specific order,  using the email as the Unique Identifier and search for the newest (find the newest using the Order Date where <code>'haspaid' = false</code>).</p>
  
  <pre><code> using ()//Insert database context here)
          {
              //Search for order in the database, try using the email as the Unique Identifire and search for the newest where haspaid = false
  
              //Change the haspaid attribute to true
              var orders = from o in db.Orders
                           where o.Email == User.Identity.Name, o.HasPaid = false, //Newest
                           select o;
              order.HasPaid = true;
              db.Orders.SaveChanges();
               //save database changes
          }
  </code></pre>