public async Task <ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { var userRepo = new Repos.UserRepo(); var billingrepo = new Repos.BillingAddressRepo(); var deliveryRepo = new Repos.DeliveryAddressRepo(); var contactRepo = new Repos.CustomerContactRepo(); //Checking if email already exists var userEmail = model.Email; var result = userRepo.GetUser(userEmail); if (result == null) { var contact = CreateContact(model); var billing = CreateBAddress(model); var delivery = CreateDAddress(model); var user = CreateUser(model, contact, billing, delivery); return(RedirectToAction("Index", "Home")); } else { return(RedirectToAction("Register", "Account")); //AddErrors(); } } // If we got this far, something failed, redisplay form return(View(model)); }
public tbl_DelivetyAddresses CreateDAddress(RegisterViewModel model) { var deliveryRepo = new Repos.DeliveryAddressRepo(); var newDAddress = new tbl_DelivetyAddresses(); newDAddress.address_line = model.AddressLine; newDAddress.suburb = model.Suburb; newDAddress.city = model.City; newDAddress.postal_code = Convert.ToInt32(model.PostalCode); newDAddress.country_id = Convert.ToInt32(model.Country); deliveryRepo.SaveDAddress(newDAddress); return(newDAddress); }