public PartialViewResult CreateWithNewAddress( NewAddressInput model ) { if ( ModelState.IsValid ) { Address Address = new Address( model.Address.Nick, model.Address.Line1, model.Address.Line2, model.Address.City, db.States.Find( model.Address.StateID ), model.Address.ZIP ); PaymentMethod PaymentMethod = new PaymentMethod ( model.CardHolderName, db.CardTypes.Find(model.CardTypeID), model.CardNumber, new DateTime( model.Year, model.Month, 1 ), model.CCV, Address ); Account.PaymentMethods.Add( PaymentMethod ); try { db.SaveChanges(); Account.Addresses.Add( Address ); db.SaveChanges(); } catch (Exception ex) { } return PartialView( "_PaymentMethods", Account.PaymentMethods ); } return PartialView(); }
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(); }
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 ); } }
public PartialViewResult CreateWithSelectedAddress( SelectedAddressInput model ) { if ( ModelState.IsValid ) { PaymentMethod PaymentMethod = new PaymentMethod ( model.CardHolderName, db.CardTypes.Find( model.CardTypeID ), model.CardNumber, new DateTime( model.Year, model.Month, 1 ), model.CCV, db.Addresses.Find(model.AddressID) ); Account.PaymentMethods.Add( PaymentMethod ); db.SaveChanges(); return PartialView( "_PaymentMethods", Account.PaymentMethods ); } return PartialView(); }