コード例 #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            FlexCustomer customer = db.Customers.Find(id);

            db.Customers.Remove(customer);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #2
0
 public ActionResult Edit([Bind(Include = "Id,FirstName,LastName,Email,PhoneNumber,MembershipId,UserId")] FlexCustomer customer)
 {
     if (ModelState.IsValid)
     {
         db.Entry(customer).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     //ViewBag.UserId = new SelectList(db.ApplicationUsers, "Id", "Email", customer.UserId);
     return(View(customer));
 }
コード例 #3
0
        // GET: Customers/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            FlexCustomer customer = db.Customers.Find(id);

            if (customer == null)
            {
                return(HttpNotFound());
            }
            return(View(customer));
        }
コード例 #4
0
        // GET: Customers/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            FlexCustomer customer = db.Customers.Find(id);

            if (customer == null)
            {
                return(HttpNotFound());
            }
            //ViewBag.UserId = new SelectList(db.ApplicationUsers, "Id", "Email", customer.UserId);
            return(View(customer));
        }
コード例 #5
0
        public ActionResult Create([Bind(Include = "Id,FirstName,LastName,Email,PhoneNumber,MembershipId,UserId")] FlexCustomer customer)
        {
            var userId      = User.Identity.GetUserId();
            var theCustomer = db.Users.Where(c => c.Id == userId).Single();

            if (ModelState.IsValid)
            {
                customer.Email  = theCustomer.Email;
                customer.UserId = User.Identity.GetUserId();
                db.Customers.Add(customer);
                db.SaveChanges();
                return(RedirectToAction("Login", "Account"));
            }

            //ViewBag.UserId = new SelectList(db.ApplicationUsers, "Id", "Email", customer.UserId);
            return(View(customer));
        }
コード例 #6
0
        public ActionResult Subscribe([Bind(Include = "Id,FirstName,LastName,Email,PhoneNumber,MembershipId,UserId")] FlexCustomer flexCustomer)
        {
            var userId      = User.Identity.GetUserId();
            var theCustomer = db.Customers.Where(c => c.UserId == userId).Single();

            //var theCustomer = db.Customers.Where(c => c.UserId == userId).Single();

            ApiConfig.Configure("flexgym-test", "test_To2cdjCqEpFHZiGqThAzu07jy0xeFnjZD");
            EntityResult result = Subscription.Create()
                                  .PlanId("basic-flex-plan")
                                  .CardFirstName(theCustomer.FirstName)
                                  .CardLastName(theCustomer.LastName)
                                  .CardNumber("4111111111111111")
                                  .CardExpiryMonth(10)
                                  .CardExpiryYear(2022)
                                  .CardCvv("999")
                                  .CustomerEmail(theCustomer.FirstName + "@test.com")
                                  .CustomerFirstName(theCustomer.FirstName)
                                  .CustomerLastName(theCustomer.LastName)
                                  .CustomerLocale("fr-CA")
                                  .CustomerPhone("+1-949-999-9999")
                                  .Request();
            Subscription subscription = result.Subscription;

            ChargeBee.Models.Customer customer = result.Customer;
            Card    card    = result.Card;
            Invoice invoice = result.Invoice;
            List <UnbilledCharge> unbilledCharges = result.UnbilledCharges;

            if (ModelState.IsValid)
            {
                theCustomer.MembershipId = "basic-flex-plan";
                //flexCustomer.MembershipId = "basic-flex-plan";
                //flexcustomer.Email = theCustomer.Email;
                //flexcustomer.UserId = User.Identity.GetUserId();
                //db.Customers.Add(customer);
                //db.Entry(flexCustomer).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index", "Home"));
            }

            return(RedirectToAction("Subscribe"));
        }