public void CreateAccount(RegisterModel model)
        {
            using (var context = new CPS_SolutionEntities())
            {
                // Duplicate account
                var account = context.Accounts.FirstOrDefault(x => x.Username == model.UserName);
                if (account != null)
                {
                    throw new MembershipCreateUserException(MembershipCreateStatus.DuplicateUserName);
                }
                // Duplicate email
                var email = context.Accounts.FirstOrDefault(x => x.Email == model.Email);
                if(email !=null)
                {
                    throw new MembershipCreateUserException(MembershipCreateStatus.DuplicateEmail);
                }

                var newUser = new Account
                {
                    Username = model.UserName,
                    Password = model.Password,
                    RoleID = model.RoleId,
                    Email = model.Email,
                    IsActive = true
                };
                context.Accounts.Add(newUser);
                context.SaveChanges();
            }
        }
 /// <summary>
 /// create new user
 /// </summary>
 /// <param name="newAccountinfo"></param>
 /// <returns></returns>
 public string CreateNewAccount(string newAccountinfo)
 {
     String[] info = newAccountinfo.Trim().Split('|');
     string username = info[0];
     string pass = info[1];
     string email = info[2];
     string role = info[3];
     var account = db.Accounts.Where(x => x.Username.Equals(username)).SingleOrDefault();
     if (account == null)
     {
         Account newacc = new Account();
         newacc.Username = username;
         newacc.Password = pass;
         newacc.Email = email;
         newacc.RoleID = Convert.ToInt32(role);
         newacc.IsActive = true;
         db.Accounts.Add(newacc);
         db.SaveChanges();
         return "";
     }
     else
     {
         return "existed";
     }
 }