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 SelectAddress(NewAddressInput model) { if (ModelState.IsValid) { ViewBag.Addresses = this.Account.Addresses.ToList(); if (this.Account.Addresses.Count > 0) { return(PartialView("_BillingAddressSelector", model as PaymentMethodInput as SelectedAddressInput)); } else { return(PartialView("_NewBillingAddress", model)); } } return(PartialView()); }