Beispiel #1
0
        public ActionResult Checkout(int id, double grandTotal, float balance, Customer customer, Item item)
        {
            try
            {
                //double GrandTotal;

                //GrandTotal = grandTotal;
                balance = customer.Balance;
                //balance -= (float)grandTotal;
                //customer.Balance = balance;
                balance -= (float)grandTotal;
                var cust = new Customer()
                {
                    CustomerID = id, Balance = balance
                };



                using (DbModelCustomers dbModelCustomer = new DbModelCustomers())
                {
                    dbModelCustomer.Customers.Attach(cust);
                    dbModelCustomer.Entry(cust).Property(x => x.Balance).IsModified = true; //.State = EntityState.Modified;
                    dbModelCustomer.SaveChanges();
                }
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
        public ActionResult Checkout(double grandTotal, float balance, Customer customer, Item item)
        {
            try
            {
                customer.Balance = customer.Balance - (float)grandTotal;

                using (DbModelCustomers dbModelCustomer = new DbModelCustomers())
                {
                    dbModelCustomer.Entry(customer).State = EntityState.Modified;
                    dbModelCustomer.SaveChanges();
                }
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
        public ActionResult Edit(int id, Customer customer)
        {
            try
            {
                using (DbModelCustomers dbModelCustomer = new DbModelCustomers())
                {
                    dbModelCustomer.Entry(customer).State = EntityState.Modified;
                    dbModelCustomer.SaveChanges();
                }

                // TODO: Add update logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
        public ActionResult BalanceChange(Customer customer)
        {
            float GT = Convert.ToInt32(Session["GT"]);

            using (DbModelCustomers dbModelCustomer = new DbModelCustomers())
            {
                var CheckingAccount = dbModelCustomer.Customers.Find(customer.CustomerID);//customer.CustomerID



                //customer.Balance = customer.Balance - GT;
                customer.Balance = 1000;
                dbModelCustomer.Entry(customer).State = EntityState.Modified;
                dbModelCustomer.SaveChanges();
                //dbModelCustomer.Customers.Add(customer);
                //dbModelCustomer.SaveChanges();
                return(RedirectToAction("Autherize", "Customer"));

                //return View();
            }
        }