public ActionResult Create(TenantViewModel vm) { if (ModelState.IsValid) { var entity = new Tenant(); Mapper.Map(vm, entity); _repo.Add(entity); return(RedirectToAction("Index")); } return(Create()); }
protected void Application_Start() { var settings = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~").AppSettings.Settings; Default.Username = settings["DefaultUsername"].Value; Default.TenantCode = settings["DefaultTenantCode"].Value; if (settings["DefaultUserPassword"] != null && settings["DefaultUserPassword"].Value.Length > 0) { var _tenantRepo = new TenantData(); _tenantRepo.Add(new Tenant { TenantCode = Default.TenantCode, TenantName = settings["DefaultTenantName"].Value, AllowLogin = true }, true); var _userRepo = new UserData(); _userRepo.Add(new User { Username = Default.Username, Password = settings["DefaultUserPassword"].Value.Encrypt(), FirstName = settings["DefaultUserFirstName"].Value, LastName = settings["DefaultUserLastName"].Value, EmailAddress = settings["DefaultUserEmailAddress"].Value, ExternalTenantCode = null, ExternalUsername = null }, true); } FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); ViewEngines.Engines.Clear(); ViewEngines.Engines.Add(new MultiTenantViewEngine()); AntiForgeryConfig.UniqueClaimTypeIdentifier = ClaimTypes.NameIdentifier; ModelMetadataProviders.Current = new ModelMetadataProvider(); }