public ActionResult Register()
        {
            var vm = new RegisterPageModelView
                         {
                             Username = "******",
                             Organization = "Organization",
                             Password = "******",
                             Password2 = "Password2"
                         };

            return View(vm);
        }
        public ActionResult Register(RegisterPageModelView viewModel)
        {
            if (string.IsNullOrEmpty(viewModel.Username)
                || string.IsNullOrEmpty(viewModel.Password))
            {
                viewModel.ErrorMessage = "Please provide your username and password";
                return View(viewModel);
            }
            if (string.IsNullOrEmpty(viewModel.Organization))
            {
                if (!Globals.Map)
                {
                    viewModel.ErrorMessage = "Please provide your company name";
                }
                else
                {
                    viewModel.ErrorMessage = "Please provide your guild name";
                }
                return View(viewModel);
            }

            if (!viewModel.Password.Equals(viewModel.Password2))
            {
                Trace.WriteLine("passwords dont match");
                viewModel.ErrorMessage = "Passwords need to match";
                return View(viewModel);
            }

            foreach (User u in _context.Users)
            {
                if (u.Name.Equals(viewModel.Username))
                {
                    viewModel.ErrorMessage = "Username already exists, please select another.";
                    return View(viewModel);
                }
            }

            //save user to the database
            var user = new User
                           {
                               Name = viewModel.Username,
                               Organization = viewModel.Organization,
                               Role = "standard",
                               Password = viewModel.Password
                           };
            var sets = new UserSettings
                           {
                               Name = viewModel.Username,
                               Organization = viewModel.Organization
                           };
            var comp = new Company
                           {
                               Name = viewModel.Organization,
                               OwnerName = viewModel.Username
                           };

            _context.Users.Add(user);
            _context.UserSettings.Add(sets);
            _context.Companies.Add(comp);
            _context.SaveChanges();

            // set the current user to newly registered one
            SimpleSessionPersister.Username = viewModel.Username;

            return RedirectToAction("Index", "Home");
        }