Esempio n. 1
0
        private void ValidatePaymentFirstCheck(PaymentCardModel payment)
        {
            Regex    regexCardNumber = new Regex("^[0-9]{1,16}$");
            Regex    regexCardCVV    = new Regex("^[0-9]{1,3}$");
            DateTime presentDate     = DateTime.Today;

            if (payment.PaymentCard.Number != null)
            {
                payment.PaymentCard.Number = payment.PaymentCard.Number.Replace(" ", "");

                if (!regexCardNumber.IsMatch(payment.PaymentCard.Number))
                {
                    ViewBag.WrongCardNumberError = Localization.CreditCardNumberMustHave16Digits;
                }
            }

            if (payment.PaymentCard.CVV != null && !regexCardCVV.IsMatch(payment.PaymentCard.CVV))
            {
                ViewBag.WrongCVVError = Localization.CVVnumberMustHave3Digits;
            }

            if (payment.PaymentCard.ExpireDate.ToString() != "1/1/0001 12:00:00 AM" && payment.PaymentCard.ExpireDate < presentDate)
            {
                ViewBag.WrongExpireDateError = Localization.CardIExpired;
            }
        }
Esempio n. 2
0
        public IActionResult AddCard()
        {
            var model = new PaymentCardModel();

            TempData["PaymentActiveMenuItem"] = "payment-sidebar-id";
            return(View(model));
        }
        public JsonResult AddPaymentCard(PaymentCard paymentCard)
        {
            PaymentCardModel paymentCardModel = new PaymentCardModel(connectionString);
            PaymentCard      newPaymentCard   = paymentCardModel.GetPaymentCardByNumber(paymentCard.cardnumber);

            if (newPaymentCard == null)
            {
                return(Json(paymentCardModel.AddPaymentCard(paymentCard)));
            }
            return(Json(newPaymentCard));
        }
Esempio n. 4
0
        public ActionResult PaymentCardForm(PaymentCardModel payment)
        {
            ValidatePaymentFirstCheck(payment);

            if (ModelState.IsValid)
            {
                var model = new PaymentModel();

                model.MakePaymentTransaction(payment.Bill.Id, payment.PayingSum);

                return(RedirectToAction("ShowBillPaidInfo", "Bill", new { bill_Id = payment.Bill.Id }));
            }

            return(View(payment));
        }
Esempio n. 5
0
        public ActionResult PaymentCardForm(PaymentCardModel payment)
        {
            Regex    regexCardNumber = new Regex("^[0-9]{1,16}$");
            Regex    regexCardCVV    = new Regex("^[0-9]{1,3}$");
            DateTime presentDate     = DateTime.Today;

            if (payment.PaymentCard.Number != null)
            {
                payment.PaymentCard.Number = payment.PaymentCard.Number.Replace(" ", "");
                if (!regexCardNumber.IsMatch(payment.PaymentCard.Number))
                {
                    ViewBag.WrongCardNumberError = "The Credit card number must have 16 digits.";
                }
            }

            if (payment.PaymentCard.CVV != null)
            {
                if (!regexCardCVV.IsMatch(payment.PaymentCard.CVV))
                {
                    ViewBag.WrongCVVError = "The CVV number must have 3 digits.";
                }
            }

            if (payment.PaymentCard.ExpireDate.ToString() != "1/1/0001 12:00:00 AM" && payment.PaymentCard.ExpireDate < presentDate)
            {
                ViewBag.WrongExpireDateError = "The card is expired";
            }

            if (ModelState.IsValid)
            {
                using (var context = new TownUtilityBillSystemEntities())
                {
                    var billDB = context.BILL.Find(payment.Bill.Id);
                    billDB.PAID = true;

                    context.SaveChanges();

                    return(RedirectToAction("ShowBillPaidInfo", "Bill", new { bill_Id = billDB.ID }));
                }
            }

            return(View(payment));
        }
Esempio n. 6
0
        public ActionResult PaymentCardForm(int bill_Id)
        {
            using (var context = new TownUtilityBillSystemEntities())
            {
                var model  = new PaymentCardModel();
                var billDB = context.BILL.Find(bill_Id);

                if (billDB != null)
                {
                    model.Bill = new Bill()
                    {
                        Id = billDB.ID, Number = billDB.NUMBER, Date = billDB.DATE, Period = CustomizedMethod.GetFullMonthName(billDB), Sum = billDB.SUM, Paid = billDB.PAID
                    }
                }
                ;

                return(View(model));
            }
        }
Esempio n. 7
0
        public ActionResult PaymentCardForm(int bill_Id)
        {
            using (var context = new TownUtilityBillSystemV2Entities())
            {
                var model  = new PaymentCardModel();
                var billDB = context.BILLs.Find(bill_Id);

                if (billDB != null)
                {
                    model.Bill = Bill.Get(billDB);
                }

                decimal accountBalance = context.ACCOUNTs.Where(a => a.ID == billDB.ACCOUNT_ID).Select(a => a.BALANCE).FirstOrDefault();

                model.PayingSum = billDB.SUM + accountBalance;

                return(View(model));
            }
        }
Esempio n. 8
0
 public IActionResult AddCard(PaymentCardModel model)
 {
     return(View(model));
 }
        public void Check_PaymentCardModel_For_CurrencyInstance()
        {
            PaymentCardModel model = new PaymentCardModel();

            Assert.IsNotNull(model.Currency);
        }
        public void Check_PaymentCardModel_For_PaymentCardTypes()
        {
            PaymentCardModel model = new PaymentCardModel();

            Assert.AreNotEqual(0, model.PaymentCardTypes.Count);
        }
        public ActionResult Confirmation(int identification,
                                         string name,
                                         string lastname,
                                         string email,
                                         int idroom,
                                         int amount,
                                         string arrivaldate,
                                         string departuredate,
                                         int paymentcardid)
        {
            ClientModel      clientModel      = new ClientModel(connectionString);
            ReservationModel reservationModel = new ReservationModel(connectionString);
            Client           clientResult     = clientModel.GetClientByidentification(identification);
            SendMail         sendMail         = null;
            RoomModel        roomModel        = new RoomModel(connectionString);
            Room             newRoom          = roomModel.GetRoomById(idroom);
            TypeRoomModel    typeRoomModel    = new TypeRoomModel(connectionString);
            TypeRoom         newTypeRoom      = typeRoomModel.GetTypeRoomByIdRoom(newRoom.id);

            if (clientResult == null)
            {
                Client newclient = new Client()
                {
                    id             = 0,
                    identification = identification,
                    name           = name,
                    lastname       = lastname,
                    email          = email
                };
                clientResult = clientModel.AddClient(newclient);
            }

            Reservation reservation = new Reservation()
            {
                id            = 0,
                idroom        = idroom,
                idClient      = clientResult.id,
                amount        = amount,
                arrivaldate   = arrivaldate,
                departuredate = departuredate,
                creationdate  = DateTime.Now.ToString("dddd, dd MMMM yyyy HH:mm:ss")
            };

            Reservation resultReservation = reservationModel.AddReservation(reservation);

            if (resultReservation != null)
            {
                sendMail = new SendMail()
                {
                    email          = clientResult.email,
                    name           = clientResult.name,
                    lastname       = clientResult.lastname,
                    identification = clientResult.identification,
                    action         = ".Su reserva en la habitación tipo " + newTypeRoom.description + " número " + newRoom.number + " ha sido exitosa, para el día " + reservation.arrivaldate +
                                     " y hasta " + reservation.departuredate +
                                     " por un monto total de " + reservation.amount + " dolares."
                };
                sendMail.SendMailAction();

                PaymentCardModel paymentModel = new PaymentCardModel(connectionString);
                var result = paymentModel.AddVoucher(paymentcardid, resultReservation.id);
                if (result < 1)
                {
                    return(View("Data"));
                }
            }

            ViewBag.Reservation = reservation;
            ViewBag.Client      = clientResult;
            ViewBag.Email       = sendMail;

            return(View());
        }