public ActionResult Delete(int id)
        {
            SavedPaymentInformation savedPaymentInformation = _db.SavedPaymentInformations.Find(id);

            _db.SavedPaymentInformations.Remove(savedPaymentInformation);
            _db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit(SavedPaymentInformation savedPaymentInformation)
 {
     if (ModelState.IsValid)
     {
         _db.Entry(savedPaymentInformation).State = EntityState.Modified;
         _db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(savedPaymentInformation));
 }
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SavedPaymentInformation savedPaymentInformation = _db.SavedPaymentInformations.Find(id);

            if (savedPaymentInformation == null)
            {
                return(HttpNotFound());
            }
            return(View(savedPaymentInformation));
        }
Exemplo n.º 4
0
        public bool CreatePayment(SavedPaymentInformationCreate model)
        {
            var entity =
                new SavedPaymentInformation()
            {
                OwnerId    = _userId,
                CardNumber = model.CardNumber,
                SavedPaymentInformationName = model.SavedPaymentInformationName,
                ExpirationDate = model.ExpirationDate,
                CVV            = model.CVV
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.SavedPaymentInformations.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }