public void RegisterTest()
        {
            using (var db = new ApplicationDbContext())
            {
                //arrange
                string password = "******";
                string email = "*****@*****.**";
                string role = "admin";
                string firstname = "Mark Joshua";
                string lastname = "Abrenica";
                RegisterViewModel registration = new RegisterViewModel()
                {
                    Password = password,
                    Email = email,
                    ConfirmPassword = password,
                     Role = role,
                      FirstName = firstname,
                      LastName = lastname
                };

                //act
                AccountController controller = new AccountController();

                bool output = controller.RegisterUser(registration);
                //assert
                Assert.IsTrue(output);

            }
        }
        public bool RegisterUser(RegisterViewModel registration)
        {
            using (var db = new ApplicationDbContext()) { 
                Account account = new Account()
                {
                    Email = registration.Email,
                   
                    Role =registration.Role,
                    DateCreated = DateTime.Now,
                    FirstName = registration.FirstName,
                    LastName = registration.LastName,
                     
                };
                try { 
                db.Accounts.Add(account);
                db.SaveChanges();
                } catch(Exception ex)
                {
                    return false;
                }
                return true;
            }

        }
        public async Task<ActionResult> Register(RegisterViewModel model)
        {

            if (ModelState.IsValid)
            {
                var user = new ApplicationUser { UserName = model.Email, Email = model.Email };
                var result = await UserManager.CreateAsync(user, model.Password);
                if (result.Succeeded)
                {
                    //register into domain model "account"
                    if (RegisterUser(model)) { 
                        await SignInManager.SignInAsync(user, isPersistent:false, rememberBrowser:false);
                    
                        // For more information on how to enable account confirmation and password reset please visit http://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>");

                        return RedirectToAction("Index", "Home");
                    }
                }
                AddErrors(result);
            }
            var db = new ApplicationDbContext();
            var data = db.AccountRoles.Select(h => new SelectListItem
            {
                Value = h.role,
                Text = h.role
            });
            SelectList list = new SelectList(data, "Value", "Text", model.Role);
            ViewBag.Roles = list;


            // If we got this far, something failed, redisplay form
            return View(model);
        }