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_BillingAddress CreateBAddress(RegisterViewModel model)
        {
            var billingrepo = new Repos.BillingAddressRepo();
            var newBAddress = new tbl_BillingAddress();

            newBAddress.address_line = model.AddressLine;
            newBAddress.suburb       = model.Suburb;
            newBAddress.city         = model.City;
            newBAddress.postal_code  = Convert.ToInt32(model.PostalCode);
            newBAddress.country_id   = Convert.ToInt32(model.Country);

            billingrepo.SaveBAddress(newBAddress);

            return(newBAddress);
        }