public ActionResult Create(SavedPaymentInformationCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new SavedPaymentInformationService(userId);

            service.CreatePayment(model);

            return(RedirectToAction("Index"));
        }
Exemplo n.º 2
0
        public IHttpActionResult Post(SavedPaymentInformationCreate pay)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = CreatePayment();

            if (!service.CreatePayment(pay))
            {
                return(InternalServerError());
            }

            return(Ok());
        }
Exemplo n.º 3
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);
            }
        }