public ActionResult AssignProfile(UserProfile  profile)
        {
            profile.TenantId = "Test id";

            db.UserProfiles.AddObject(profile);
            db.SaveChanges();

            return RedirectToAction("Index");
        }
Пример #2
0
        public ActionResult AssignProfile()
        {
            var profile = new MultiTenantAuthentication.Models.UserProfile();

            // default value
            profile.Username = User.Identity.Name;

            return(View(profile));
        }
        public ActionResult AssignProfile()
        {
            var profile = new MultiTenantAuthentication.Models.UserProfile();

            // default value
            profile.Username = User.Identity.Name;

            return View(profile);
        }
        public ActionResult CreateLogin(FormCollection form, TenantLoginViewModel model)
        {
            //todo: implement role for users!  Please design the architecture first!!!
            var tenantDb = new TenantRegistryEntities();
            var tenant = new Tenant
            {
                id = System.Guid.NewGuid().ToString(),
                Name = model.Tenant.Name,
                db = System.Web.Configuration.WebConfigurationManager.AppSettings["NewTenantDatabaseName"],  // todo: Default Tenant db must be get from a separate class
                ConnectionStringName = System.Web.Configuration.WebConfigurationManager.AppSettings["NewTenantConnectionString"] // todo: Tenant connection string must be get from a separate class
            };

            var userprofile = new UserProfile
            {
                Username = model.UserProfile.Username,
                FirstName = model.UserProfile.FirstName,
                LastName = model.UserProfile.LastName
            };

            // Save tenant
            tenant.UserProfiles.Add(userprofile);
            tenantDb.Tenants.AddObject(tenant);
            tenantDb.SaveChanges();

            // Create asp.net login
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                var pw = form["Password"].ToString();
                var email = form["Email"].ToString();
                MembershipCreateStatus createStatus = MembershipService.CreateUser(model.UserProfile.Username, pw, email);

                if (createStatus == MembershipCreateStatus.Success)
                {
                    //FormsService.SignIn(model.UserProfile.Username, false /* createPersistentCookie */);
                    return RedirectToAction("Index", "Home");
                }
                else
                {
                    ModelState.AddModelError("", AccountValidation.ErrorCodeToString(createStatus));
                }
            }

            return View("Index");
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the UserProfiles EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToUserProfiles(UserProfile userProfile)
 {
     base.AddObject("UserProfiles", userProfile);
 }
 /// <summary>
 /// Create a new UserProfile object.
 /// </summary>
 /// <param name="username">Initial value of the Username property.</param>
 /// <param name="tenantId">Initial value of the TenantId property.</param>
 public static UserProfile CreateUserProfile(global::System.String username, global::System.String tenantId)
 {
     UserProfile userProfile = new UserProfile();
     userProfile.Username = username;
     userProfile.TenantId = tenantId;
     return userProfile;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the UserProfiles EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToUserProfiles(UserProfile userProfile)
 {
     base.AddObject("UserProfiles", userProfile);
 }