public ActionResult Create(NewOrganizationViewModel model)
        {
            var org = model.Org;
            if (ModelState.IsValid)
            {
                using (var ctx = GetRepository())
                {
                    ctx.Users.Attach(Permissions.User);

                    // Default status types
                    org.UnitStatusTypes.Add(new UnitStatusType { Name = "Active", IsActive = true, IsMissionQualified = true, Organization = org });
                    org.UnitStatusTypes.Add(new UnitStatusType { Name = "Inactive", IsActive = false, IsMissionQualified = false, Organization = org });

                    ctx.Organizations.Add(org);

                    ctx.InitializeOrganizationSecurity(org, Permissions.User);

                    ctx.SaveChanges();

                    return RedirectToAction("Home", new { q = org.Id });
                }
            }

            // If we got this far, something failed - redisplay form
            return View(model);
        }
 public ActionResult Create()
 {
     string selectedRole = AuthIdentityService.USERS_ROLE;
     var arguments = new NewOrganizationViewModel
     {
         Org = new SarUnit { AdminAccount = Permissions.UserLogin },
         Visibility = selectedRole
     };
     ViewData[OrganizationsController.VIEWDATA_LIST_TIMEZONES] = new SelectList(TimeZoneInfo.GetSystemTimeZones().Select(f => new { Id = f.Id, Name = string.Format("[{0}{1:hh\\:mm}] {2}", (f.BaseUtcOffset.TotalHours < 0) ? '-' : '+', f.BaseUtcOffset, f.StandardName) }), "Id", "Name");
     ViewData[OrganizationsController.VIEWDATA_LIST_VISIBILITY] = new SelectList(new[] { AuthIdentityService.EVERYONE_ROLE, AuthIdentityService.USERS_ROLE, AuthIdentityService.MISSION_VIEWERS_ROLE, "Restricted" }, selectedRole);
     return View(arguments);
 }