コード例 #1
0
        public ActionResult Create([Bind(Include = "ID,Name")] BankerType bankerType)
        {
            if (ModelState.IsValid)
            {
                db.BankerType.Add(bankerType);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(bankerType));
        }
コード例 #2
0
        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));
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        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));
        }
コード例 #5
0
        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();
                }
            }
        }
コード例 #6
0
        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());
            }
        }