public ActionResult Create(CreateModel model)
        {
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                MembershipCreateStatus createStatus = MembershipService.CreateUser(model.UserName, model.Password, model.Email);

                if (createStatus == MembershipCreateStatus.Success)
                {
                    UserProfile profile = UserProfile.GetUserProfile(model.UserName);
                    profile.FirstName = model.FirstName;
                    profile.LastName = model.LastName;
                    profile.Phone = model.Phone;
                    profile.CompanyId = model.CompanyId;
                    profile.Save();
                    if (model.SelectedRoles != null)
                    {
                        Roles.AddUserToRoles(model.UserName, model.SelectedRoles);
                    }
                    return RedirectToAction("Index");
                }
                else
                {
                    ModelState.AddModelError("", AccountValidation.ErrorCodeToString(createStatus));
                }
            }
            var companies = CompaniesRepository.Get();
            model.Companies = new SelectList(companies, "CompanyId", "Name");
            string[] allRoles = Roles.GetAllRoles();
            model.Roles = new MultiSelectList(allRoles);
            // If we got this far, something failed, redisplay form
            ViewBag.PasswordLength = MembershipService.MinPasswordLength;
            return View(model);
        }
 //
 // GET: /Users/Create
 public ActionResult Create()
 {
     CreateModel model = new CreateModel();
     ViewBag.PasswordLength = MembershipService.MinPasswordLength;
     var companies = CompaniesRepository.Get();
     model.Companies = new SelectList(companies, "CompanyId", "Name");
     string[] allRoles = Roles.GetAllRoles();
     model.Roles = new MultiSelectList(allRoles);
     return View(model);
 }