Ejemplo n.º 1
0
        public ActionResult AddNewCard( int id,FormCollection collection)
        {
            string message = string.Empty;
            string cardType = string.Empty;
            switch (id)
            {
                case 1:
                    cardType = Constant.CardType.VISACREDIT;
                    break;
                default:
                    cardType = Constant.CardType.VISACREDIT;
                    break;
            }
            PaymentMethod paymentMethod = new PaymentMethod();
            paymentMethod.CardType = cardType;
            paymentMethod.Name = collection["NameOnCard"];
            paymentMethod.Description = "Payment menthod: "+id;
            paymentMethod.CreditCardNumber = collection["CreditCardNumber"];
            paymentMethod.NameOnCard = collection["NameOnCard"];
            paymentMethod.CardCvv2 = collection["CardCvv2"];
            paymentMethod.MaskedCreditCardNumber = collection["CardCvv2"];
            string monthFrom = collection["MonthFrom"];
            string monthTo = collection["MonthTo"];
            string yearFrom = collection["YearFrom"];
            string yearTo = collection["YearTo"];
            DateTime dateFrom = new DateTime(yearFrom.ToInt32(), monthFrom.ToInt32(), 1);
            DateTime dateTo = new DateTime(yearTo.ToInt32(), monthTo.ToInt32(), 28);
            paymentMethod.ValidFrom = dateFrom;
            paymentMethod.ValidTo = dateTo;
            paymentMethod.CardExpirationMonth = monthTo;
            paymentMethod.CardExpirationYear = yearTo;
            paymentMethod.Address = collection["Address"];
            paymentMethod.Country = collection["Country"];
            paymentMethod.Zipcode = collection["Zipcode"];
            paymentMethod.Email = SessionManager.USER_EMAIL;
            paymentMethod.Bank = collection["Bank"];
            paymentMethod.ClassName = Constant.PaymentClass.APCOService;
            paymentMethod.Verified = false;
            paymentMethod.AddedDate = DateTime.Now;
            paymentMethod.ModifyDate = DateTime.Now;

            try
            {
                IoC.Resolve<IPaymentService>().InsertPaymentMethod(paymentMethod);
                message = "Insert card successfully!";
            }
            catch (Exception ex)
            {
                message = "Error: " + ex.Message;
            }
            //update load data
            ViewBag.CartType = id.ToString();
            ViewBag.ListMonth = IoC.Resolve<ICommonService>().MakeSelectListMonth();
            ViewBag.ListYear = IoC.Resolve<ICommonService>().MakeSelectListYearCard();
            ViewBag.ListCountry = IoC.Resolve<ICommonService>().getAllCountry();
            ViewBag.Message = message;
            return View();
        }
Ejemplo n.º 2
0
        public void UpdatePaymentMethod(PaymentMethod paymentMethod)
        {
            if (paymentMethod == null)
                throw new ArgumentNullException("paymentMethod");

            paymentMethod.Name = CommonHelper.EnsureNotNull(paymentMethod.Name);
            paymentMethod.Name = CommonHelper.EnsureMaximumLength(paymentMethod.Name, 100);
            paymentMethod.Description = CommonHelper.EnsureNotNull(paymentMethod.Description);
            paymentMethod.Description = CommonHelper.EnsureMaximumLength(paymentMethod.Description, 4000);
            paymentMethod.CreditCardNumber = CommonHelper.EnsureNotNull(paymentMethod.CreditCardNumber);
            paymentMethod.CreditCardNumber = CommonHelper.EnsureMaximumLength(paymentMethod.CreditCardNumber, 30);
            paymentMethod.NameOnCard = CommonHelper.EnsureNotNull(paymentMethod.NameOnCard);
            paymentMethod.NameOnCard = CommonHelper.EnsureMaximumLength(paymentMethod.NameOnCard, 100);
            paymentMethod.ValidFrom = paymentMethod.ValidFrom;
            paymentMethod.ValidTo = paymentMethod.ValidTo;
            paymentMethod.CardExpirationMonth = paymentMethod.CardExpirationMonth;
            paymentMethod.CardExpirationYear = paymentMethod.CardExpirationYear;
            paymentMethod.Address = paymentMethod.Address;
            paymentMethod.Country = paymentMethod.Country;
            paymentMethod.Zipcode = paymentMethod.Zipcode;
            paymentMethod.Email = paymentMethod.Email;
            paymentMethod.Bank = paymentMethod.Bank;
            paymentMethod.Branch = paymentMethod.Branch;
            paymentMethod.BranchCode = paymentMethod.BranchCode;
            paymentMethod.SwiftCode = paymentMethod.SwiftCode;
            paymentMethod.IBAN = paymentMethod.IBAN;
            paymentMethod.Verified = paymentMethod.Verified;

            _context.SaveChanges();
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Inserts a payment method
 /// </summary>
 /// <param name="paymentMethod">Payment method</param>
 public void InsertPaymentMethod(PaymentMethod paymentMethod)
 {
     _context.PaymentMethods.AddObject(paymentMethod);
     _context.SaveChanges();
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Deprecated Method for adding a new object to the PaymentMethods EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToPaymentMethods(PaymentMethod paymentMethod)
 {
     base.AddObject("PaymentMethods", paymentMethod);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Create a new PaymentMethod object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="creditCardNumber">Initial value of the CreditCardNumber property.</param>
 /// <param name="nameOnCard">Initial value of the NameOnCard property.</param>
 /// <param name="validFrom">Initial value of the ValidFrom property.</param>
 /// <param name="validTo">Initial value of the ValidTo property.</param>
 public static PaymentMethod CreatePaymentMethod(global::System.Int64 id, global::System.String name, global::System.String creditCardNumber, global::System.String nameOnCard, global::System.DateTime validFrom, global::System.DateTime validTo)
 {
     PaymentMethod paymentMethod = new PaymentMethod();
     paymentMethod.ID = id;
     paymentMethod.Name = name;
     paymentMethod.CreditCardNumber = creditCardNumber;
     paymentMethod.NameOnCard = nameOnCard;
     paymentMethod.ValidFrom = validFrom;
     paymentMethod.ValidTo = validTo;
     return paymentMethod;
 }