コード例 #1
0
 public ActionResult Create( PaymentMethodInput model = null)
 {
     ViewBag.CardTypes = new SelectList(db.CardTypes.ToList(), "RID", "Title");
     ViewBag.Months = new SelectList(new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 });
     var years = new Collection<int>();
     for(int i = 0; i <= 20; i++)
     {
         years.Add( i + DateTime.Now.Year );
     }
     ViewBag.Years = new SelectList( years );
     return PartialView( "_CreatePaymentMethod", model );
 }
コード例 #2
0
 public PartialViewResult CreateCallback( PaymentMethodInput model )
 {
     if ( ModelState.IsValid )
     {
         ViewBag.Addresses = this.Account.Addresses.ToList();
         if( this.Account.Addresses.Count > 0)
         {
             return PartialView( "_BillingAddressSelector", model as SelectedAddressInput );
         }
         else
         {
             return PartialView( "_NewBillingAddress", model as NewAddressInput );
         }
     }
     return PartialView();
 }
コード例 #3
0
				public PartialViewResult EditPaymentMethod( PaymentMethodInput model )
				{
					if ( ModelState.IsValid )
					{
						PaymentMethod PaymentMethod = new PaymentMethod();

						db.Entry( PaymentMethod ).State = EntityState.Modified;
						db.SaveChanges();
						return PartialView( "_PaymentMethods", Account.PaymentMethods );
					}
					return PartialView();
				}
コード例 #4
0
				public PartialViewResult CreatePaymentMethod( PaymentMethodInput model )
				{
					if ( ModelState.IsValid )
					{
						PaymentMethod PaymentMethod = new PaymentMethod( );
						Account.PaymentMethods.Add( PaymentMethod );
						db.SaveChanges();
						return PartialView( "PaymentMethods", Account.PaymentMethods );
					}
					else
					{
						ModelState.AddModelError( "CreatePaymentMethodFailure", "There were errors with the Payment Method." );
						Response.StatusCode = 400;
						Response.StatusDescription = "<h4>There were errors:</h4><p>One or more of the fields could not be saved. Please review the form and ensure everything is valid.</p>";
						return PartialView( "_PaymentMethods", Account.PaymentMethods );
					}
				}