public ActionResult ViewBalance() { string userID = User.Identity.GetUserId(); Customer currentCustomer = (from row in db.Customers where row.UserId == userID select row).FirstOrDefault(); BilingAccount model = (from row in db.BillingAccounts where row.CustomerId == currentCustomer.ID select row).FirstOrDefault(); return(View(model)); }
public ActionResult PickUp(int?id) { BilingAccount BillingAccount; try { BillingAccount = (from row in db.BillingAccounts where row.CustomerId == (int)id select row).First(); BillingAccount.Balance += 20; BillingAccount.LastChargeDate = "Today"; } catch { BillingAccount = new BilingAccount(); BillingAccount.CustomerId = (int)id; BillingAccount.Balance = 20; BillingAccount.LastChargeDate = "Today"; db.BillingAccounts.Add(BillingAccount); } db.SaveChanges(); return(View("PickedUp")); }