コード例 #1
0
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            paymentoption paymentoption = await db.paymentoptions.FindAsync(id);

            if (paymentoption == null)
            {
                return(HttpNotFound());
            }
            return(View(paymentoption));
        }
コード例 #2
0
        public async Task <ActionResult> Edit([Bind(Include = "creditcardnumber,creditcardcompany,expireddate")] paymentoption paymentoption)
        {
            string result = "";

            if (ModelState.IsValid)
            {
                db.Entry(paymentoption).State = EntityState.Modified;
                await db.SaveChangesAsync();

                //return RedirectToAction("Index");
                result = "true";
            }
            //return View(paymentoption);
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
コード例 #3
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            string result = "";

            try
            {
                paymentoption paymentoption = await db.paymentoptions.FindAsync(id);

                db.paymentoptions.Remove(paymentoption);
                await db.SaveChangesAsync();

                //return RedirectToAction("Index");
                result = "true";
            }
            catch (Exception ex)
            {
                result = "false";
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
コード例 #4
0
        public async Task <ActionResult> addCardToUser([Bind(Include = "username,cardnumber")] CardBelongsTo model)
        {
            string result = "";

            if (ModelState.IsValid)
            {
                paymentoption card = await db.paymentoptions.FindAsync(model.cardnumber);

                if (card != null)
                {
                    user user = await db.users.FindAsync(model.username);

                    user.paymentoptions.Add(card);
                    await db.SaveChangesAsync();

                    result = "true";
                }
                else
                {
                    result = "false";
                }
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
コード例 #5
0
        public async Task <ActionResult> Create([Bind(Include = "creditcardnumber,creditcardcompany,expireddate")] paymentoption paymentoption)
        {
            string result = "";

            if (ModelState.IsValid)
            {
                paymentoption dbCard = await db.paymentoptions.FindAsync(paymentoption.creditcardnumber);

                if (dbCard == null)
                {
                    db.paymentoptions.Add(paymentoption);
                    await db.SaveChangesAsync();

                    //return RedirectToAction("Index");
                    result = "true";
                }
                else
                {
                    result = "false";
                }
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
            //return View(paymentoption);
        }