private UKAddress InsertNewUKCardAddress(CardPaymentViewModel model) { var cardAddress = new UKAddress { AddressLine1 = model.CardAddress.AddressLine1, AddressLine2 = model.CardAddress.AddressLine2, Town = model.CardAddress.Town, County = model.CardAddress.County, Postcode = model.CardAddress.Postcode }; _context.UKAddresses.Add(cardAddress); _context.SaveChanges(); return(cardAddress); }
public IActionResult RegisterCard(CardPaymentViewModel model) { if (ModelState.IsValid) { if (!LuhnCheck(model.CardNumberString) || !CardExpiryDateIsValid(model.ExpiryDate)) { return(View()); } UKAddress cardAddress = InsertNewUKCardAddress(model); //This method is just here for illustrative purposes and to tie the registered card to a customer var customerId = GetCustomerId(); InsertCardDetails(model, cardAddress.ID, customerId); ModelState.Clear(); } else { return(View(model)); } return(View()); }