[TestMethod] public void CreateCashTest() { var view = GetRandom.Object <CashView>(); var cash = PaymentMethodViewFactory.Create(view); Assert.IsInstanceOfType(cash, typeof(Cash)); }
[TestMethod] public void CreateCheckViewTest() { var check = GetRandom.Object <Check>(); var view = PaymentMethodViewFactory.Create(check) as CheckView; Assert.IsInstanceOfType(view, typeof(CheckView)); validateCheck(view, check); }
[TestMethod] public void CreateCreditCardTest() { var view = GetRandom.Object <CreditCardView>(); view.ValidTo = GetRandom.DateTime(view.ValidFrom); var card = PaymentMethodViewFactory.Create(view); Assert.IsInstanceOfType(card, typeof(CreditCard)); validateCreditCard(view, card); }
[TestMethod] public void CreateCheckTest() { var view = GetRandom.Object <CheckView>(); view.ValidTo = GetRandom.DateTime(view.ValidFrom); var check = PaymentMethodViewFactory.Create(view); Assert.IsInstanceOfType(check, typeof(Check)); validateCheck(view, check); }
[TestMethod] public void CreateCashViewTest() { var cash = GetRandom.Object <Cash>(); var view = PaymentMethodViewFactory.Create(cash); Assert.IsInstanceOfType(view, typeof(CashView)); Assert.AreEqual("Cash", view.ID); Assert.AreEqual(null, view.ValidFrom); Assert.AreEqual(null, view.ValidTo); }
[TestMethod] public void CreateCreditCardViewTest() { var data = GetRandom.Object <CreditCardData>(); data.CurrencyID = data.Currency.ID; var card = new CreditCard(data); var view = PaymentMethodViewFactory.Create(card) as CreditCardView; Assert.IsInstanceOfType(view, typeof(CreditCardView)); validateCreditCard(view, card); }
[HttpPost] public async Task <IActionResult> CreateCreditCard( [Bind(creditCardProperties)] CreditCardView c) { if (!ModelState.IsValid) { return(View(c)); } c.ID = c.ID ?? Guid.NewGuid().ToString(); var o = PaymentMethodViewFactory.Create(c); await paymentMethods.AddObject(o); return(RedirectToAction("Index")); }
[HttpPost] public async Task <IActionResult> EditDebitCard( [Bind(debitCardProperties)] DebitCardView c) { if (!ModelState.IsValid) { return(View(c)); } var o = await paymentMethods.GetObject(c.ID) as DebitCard; var n = PaymentMethodViewFactory.Create(c); copyDbRecords(o.Data, n.Data); await paymentMethods.UpdateObject(o); return(RedirectToAction("Index")); }
public async Task <IActionResult> Delete(string id) { var paymentMethod = await paymentMethods.GetObject(id); switch (paymentMethod) { case Check check: return(View("DeleteCheck", PaymentMethodViewFactory.Create(check) as CheckView)); case DebitCard debitCard: return(View("DeleteDebitCard", PaymentMethodViewFactory.Create(debitCard) as DebitCardView)); case CreditCard creditCard: return(View("DeleteCreditCard", PaymentMethodViewFactory.Create(creditCard) as CreditCardView)); } return(RedirectToAction("Index")); }
public async Task <IActionResult> EditDebitCard(string id) { var paymentMethod = await paymentMethods.GetObject(id) as DebitCard; return(View(PaymentMethodViewFactory.Create(paymentMethod) as DebitCardView)); }