public async Task <ActionResult> Register(RegisterAndCustomerVM model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.regVM.Email, Email = model.regVM.Email
                };
                var result = await UserManager.CreateAsync(user, model.regVM.Password);

                if (result.Succeeded)
                {
                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    using (var db = new InsuranceQuoteDBEntities())
                    {
                        var customer = new Customer
                        {
                            FirstName   = model.custVM.FirstName,
                            LastName    = model.custVM.LastName,
                            DateOfBirth = model.custVM.DateOfBirth
                        };
                        db.Customers.Add(customer);
                        _ = await db.SaveChangesAsync();

                        var custUser = new CustomerAspNetUser {
                            CustomerID = customer.Id, AspNetUserID = user.Id
                        };
                        db.CustomerAspNetUsers.Add(custUser);
                        _ = await db.SaveChangesAsync();
                    }
                    return(RedirectToAction("Index", "Home"));
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
 public async Task <ActionResult> Index(IndexViewAndCustomerVM model)
 {
     using (var db = new InsuranceQuoteDBEntities())
     {
         var cust = db.Customers.Find(model.custVM.Id);
         cust.FirstName   = model.custVM.FirstName;
         cust.LastName    = model.custVM.LastName;
         cust.DateOfBirth = model.custVM.DateOfBirth;
         _ = await db.SaveChangesAsync();
     }
     return(RedirectToAction("Index", new { Message = ManageMessageId.UpdatePersonalInfoSuccess }));
 }