public async Task<ActionResult> Signup(SignUpViewModel model)
        {
            if (ModelState.IsValid)
            {
                User admin = new User();
                List<User> listAdmin = DataHelper.GetAllUsers();

                List<User> newAdmin = DataHelper.GetUsersByKeyword(model.UserName);
                if (newAdmin.Count == 0)
                {
                    User newAdmin1 = new User();
                    newAdmin1.UserName = model.UserName;
                    newAdmin1.UserPassword = model.Password;
                    DataHelper.AddAdmin(newAdmin1);
                    
                    ModelState.AddModelError("", "Sucessful!");
                }
                else
                {
                    ModelState.AddModelError("", "Username is existed");
                }
                //var user = new ApplicationUser { UserName = model.Username, Email = model.Email };
                //var result = await UserManager.CreateAsync(user, model.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 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);
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
        public async Task<ActionResult> SignUpPost(SignUpViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new User();
                var listUser = new List<User>();
                listUser = db.Users.ToList();
                var newUser = listUser.FindAll(a => a.UserName.Equals(model.UserName));
                if (newUser.Count != 0)
                {
                    //ModelState.AddModelError("", "UserName is already exist. Please choose another.");
                    return Json(new
                    {
                        state = 0,
                        message = "UserName is already exist. Please choose another."
                    });
                }
                newUser = listUser.FindAll(a => a.UserEmail.Equals(model.Email));
                if (newUser.Count != 0)
                {
                    //ModelState.AddModelError("", "Email is already registered. Please choose another.");
                    return Json(new
                    {
                        state = 0,
                        message = "Email is already registered. Please choose another."
                    });
                }
                UserDatabaseHelper.Instance.AddNewUser(model, user);

                UserHelpers.SetCurrentUser(Session, user);

                //Create Channel
                UserDatabaseHelper.Instance.CreateUserChannel(user);
                //Send email confirm
                MailHelpers.Instance.SendMailWelcome(user.UserEmail,user.UserFirstName,user.UserLastName);
                //return RedirectToAction("RegisterSuccess", "Account");
                return Json(new
                {
                    state = 1,
                    message = "Registered Successfully"
                });
            }

            // If we got this far, something failed, redisplay form
            return Json(new
            {
                state = 0,
                message = "Something Wrong"
            });
        }