public ActionResult Create([Bind(Include = "ID,Name")] BankerType bankerType) { if (ModelState.IsValid) { db.BankerType.Add(bankerType); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(bankerType)); }
public ActionResult Create([Bind(Include = "ID,AccountTypeId,Amount,CustomerId")] Account account) { if (ModelState.IsValid) { db.Account.Add(account); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(account)); }
public ActionResult Create([Bind(Include = "ID,TransactionTypeId,BankerId,AccountId,Amount")] CustomerTransaction customerTransaction) { if (ModelState.IsValid) { db.CustomerTransaction.Add(customerTransaction); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(customerTransaction)); }
public ActionResult Create([Bind(Include = "ID,FirstName,LastName,BankerTypeId")] Banker banker) { if (ModelState.IsValid) { db.Banker.Add(banker); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(banker)); }
public static void Initialize(IServiceProvider serviceProvider) { var serviceScope = serviceProvider.CreateScope(); using (BankingDBContext context = serviceScope.ServiceProvider.GetRequiredService <BankingDBContext>()) { try { context.Database.Migrate(); } catch (Exception ex) { } if (!context.Accounts.Any()) { context.Accounts.Add(new Account { AccountType = "Calculation", AccountBalance = 1000 }); context.Accounts.Add(new Account { AccountType = "Translation", AccountBalance = 1000 }); context.SaveChanges(); } } }
public ActionResult Edit(int id, FormCollection collection) { try { // TODO: Add update logic here var custObj = customerDB.Customer.Single(cust => cust.ID == id); if (TryUpdateModel(custObj)) { customerDB.SaveChanges(); } return(RedirectToAction("Index")); } catch { return(View()); } }