public IActionResult Create([Bind("ShippingID,AddressNum,AddressStreet,AddressCity,AddressState,AddressZipCode")] Shipping shipping, string num, string zip) { if (int.TryParse(zip, out int z) && zip.Length == 5 && int.TryParse(num, out int n) && num.Length > 0) { shipping.AddressNum = int.Parse(num); shipping.AddressZipCode = zip; DatabaseControl.AddNewShippingInformationToUser(shipping, Storage.GetCustomer(), _context); List <Shipping> shippingOptions = DatabaseControl.GetShippingAddresssesOnFileForCustomer(Storage.GetCustomer(), _context); return(View("ShippingOptions", shippingOptions)); } else { ViewData["invalidAddress"] = "One or more input parameters were invalid. Please try again."; return(View("Create")); } }
public IActionResult Create([Bind("BillingID,NameOnCard,CardNumber,SecurityCode,AddressNum,AddressStreet,AddressCity,AddressState,AddressZipCode")] Billing billing, string yearMonth, string num, string zip, string security) { if (yearMonth != null && billing.CardNumber.Length == 16 && int.TryParse(billing.CardNumber.Substring(0, 7), out int cn1) && int.TryParse(billing.CardNumber.Substring(8), out int cn2) && security.Length == 3 && int.TryParse(security, out int s) && int.TryParse(zip, out int z) && zip.Length == 5 && int.TryParse(num, out int n) && num.Length > 0) { billing.AddressNum = int.Parse(num); billing.ExpirationYear = int.Parse(yearMonth.Substring(0, 4)); billing.ExpirationMonth = int.Parse(yearMonth.Substring(5)); billing.SecurityCode = int.Parse(security); billing.AddressZipCode = zip; DatabaseControl.AddNewCardInformationToUser(billing, Storage.GetCustomer(), _context); DatabaseControl.AddNewShippingInformationToUser(billing, Storage.GetCustomer(), _context); List <Billing> cardsOnFile = DatabaseControl.GetCardsOnFileForCustomer(Storage.GetCustomer(), _context); return(View("BillingOptions", cardsOnFile)); } else { ViewData["invalidCard"] = "One or more input parameters were invalid. Please try again."; return(View("Create")); } }