public ActionResult Delete(int ItemID)
        {
            Payment Payment = PaymentBusiness.Find(ItemID);

            Payment.Draft        = true;
            Payment.ModifiedDate = DateTime.Now;
            PaymentBusiness.Update(Payment);
            PaymentBusiness.Save();
            return(RedirectToAction("Index"));
        }
示例#2
0
        public Payment Execute(Payment payment)
        {
            payment.Order   = _ordersBusiness.Get(payment.Order.Key);
            payment.OrderId = payment.Order.Id;
            long idPayment = _paymentBusiness.Insert((Payment)payment);

            if (payment.Valid)
            {
                if (payment is Billet)
                {
                    ResponsePaymentSlipTransation response =
                        _billetIntegration.Execute(
                            new RequestPaymentSlipTransaction()
                    {
                        reference = payment.Order.Number
                    }
                            );
                    payment.State       = "ok";
                    payment.PaymentType = PaymentType.Billet;
                }
                else if (payment is CredCard)
                {
                    ResponseCreditCardTransaction response =
                        _credCardIntegration.Execute(
                            new RequestCreditCardTransation()
                    {
                        reference = payment.Order.Number,
                        number    = ((CredCard)payment).Number
                    });
                    payment.State       = "ok";
                    payment.PaymentType = PaymentType.CredCard;
                }
                payment.Id = idPayment;
                _paymentBusiness.Update((Payment)payment);
            }
            return(payment);
        }
示例#3
0
        public Payment Update(Payment value)
        {
            _paymentBusiness.Update(value);

            return(value);
        }
        public ActionResult Subcriber(string cardNumber, string email, string expityMonth, string expityYear, string CV)
        {
            int  n = 0;
            long m = 0;

            if (cardNumber.Length != 12 || !long.TryParse(cardNumber, out m))
            {
                ModelState.AddModelError(string.Empty, "Card's not valid!");
            }
            if (expityMonth.Length > 2 || !int.TryParse(expityMonth, out n) || n > 12 || n < DateTime.Now.Month)
            {
                ModelState.AddModelError(string.Empty, "Month not valid!");
            }
            if (expityYear.Length != 4 || !int.TryParse(expityYear, out n) || n < DateTime.Now.Year)
            {
                ModelState.AddModelError(string.Empty, "Year not valid!");
            }
            if (CV.Length != 3 || !int.TryParse(CV, out n))
            {
                ModelState.AddModelError(string.Empty, "CVG not valid!");
            }
            using (var context = new EgreetingContext())
            {
                if (!context.Set <Subcriber>().Any(x => x.Email.Equals(email)))
                {
                    ModelState.AddModelError(string.Empty, "Subcriber not found!");
                }
            }

            if (!ModelState.IsValid)
            {
                return(View(ViewNamesConstant.FrontendPaymentsSubcriber));
            }
            var      listPayment = new List <int>();
            DateTime maxMonth    = DateTime.Now;

            using (var context = new EgreetingContext())
            {
                listPayment = context.Set <Payment>().Where(x => x.EgreetingUser.Email.Equals(email) &&
                                                            x.Draft != true &&
                                                            x.PaymentStatus == false &&
                                                            x.Month >= DateTime.Now.Month &&
                                                            x.Year == DateTime.Now.Year
                                                            ).OrderBy(x => x.Year).ThenBy(x => x.Month).Select(x => x.PaymentID).ToList();
                if (listPayment.Count > 0)
                {
                    var paymentMonthMax = context.Set <Payment>().Where(x => x.EgreetingUser.Email.Equals(email) &&
                                                                        x.Draft != true &&
                                                                        x.PaymentStatus == false &&
                                                                        x.Month >= DateTime.Now.Month &&
                                                                        x.Year == DateTime.Now.Year
                                                                        ).OrderByDescending(x => x.Year).ThenByDescending(x => x.Month).Take(1).FirstOrDefault();
                    maxMonth = new DateTime(paymentMonthMax.Year, paymentMonthMax.Month, 1);
                }
                else
                {
                    ModelState.AddModelError(string.Empty, "Subcriber has paid for this month!");
                    return(View(ViewNamesConstant.FrontendPaymentsSubcriber));
                }
            }
            foreach (var id in listPayment)
            {
                var item = PaymentBusiness.Find(id);
                item.PaymentStatus = true;
                item.ModifiedDate  = DateTime.Now;
                item.EgreetingUser.PaymentDueDate = maxMonth.AddMonths(1);
                PaymentBusiness.Update(item);
                PaymentBusiness.Save();
            }
            return(Redirect("/"));
        }