コード例 #1
0
        public void DeleteRole(string rolename)
        {
            RoleUserTypeMappings model = new RoleUserTypeMappings();
            aspnet_Roles         role  = GetRoleInfoByName(rolename);

            db.Core_DeleteRole(role.RoleId);
        }
        public void SetRoleAuthorization(string roleName, List <int?> ControllerActionIDList)
        {
            aspnet_Roles role = DB.aspnet_Roles.SingleOrDefault(r => r.RoleName == roleName);

            if (role != null)
            {
                if (ControllerActionIDList == null)
                {
                    ControllerActionIDList = new List <int?>();
                }

                List <MVCAuthorization> deleteList = role.MVCAuthorizations.Where(r => !ControllerActionIDList.Contains(r.ControllerActionID)).ToList();

                for (int i = 0; i < deleteList.Count(); i++)
                {
                    DB.DeleteObject(deleteList[i]);
                }

                DB.SaveChanges();

                IEnumerable <int?> addList = ControllerActionIDList.Except(role.MVCAuthorizations.Select(r => r.ControllerActionID));

                foreach (var item in addList)
                {
                    MVCAuthorization mvcAuthorization = new MVCAuthorization();
                    mvcAuthorization.aspnet_Roles       = role;
                    mvcAuthorization.ControllerActionID = item;
                    DB.AddToMVCAuthorizations(mvcAuthorization);
                }
                DB.SaveChanges();
            }
        }
コード例 #3
0
        private void editRole(aspnet_Roles role)
        {
            aspnet_Roles roleold = Uow.aspnet_Roles.GetAll().FirstOrDefault(r => r.RoleId == role.RoleId);

            roleold.Description = role.Description;
            Uow.aspnet_Roles.Update(roleold);
            Uow.Commit();
        }
コード例 #4
0
        public ActionResult DeleteConfirmed(Guid id)
        {
            aspnet_Roles aspnet_roles = db.aspnet_Roles.Find(id);

            db.aspnet_Roles.Remove(aspnet_roles);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #5
0
        public Guid SaveLandload(int baseHouseId)
        {
            Guid landlordId;

            List <BaseHouse> dormHouses = BaseHouseDAO.SelectAllByHouseTypeId(HouseTypeId);

            CurrentHouse = dormHouses.Find(bh => bh.BaseHouseId == baseHouseId);
            if (CurrentHouse.LandlordId.HasValue)
            {
                landlordId = CurrentHouse.LandlordId.Value;
            }
            else
            {
                aspnet_Roles aspnet_Roles_ = new aspnet_Roles();
                Landlord     landload      = new Landlord();
                aspnet_Roles_ = aspnet_Roles.Select("landlord");

                User Landlorduser = new User();

                Landlorduser.UserId = Guid.NewGuid();
                landlordId          = Landlorduser.UserId.Value;

                Landlorduser.PersonalEmail     = CurrentHouse.ManagerEmail;
                Landlorduser.FirstName         = CurrentHouse.PropertyManagementCompanyName;
                Landlorduser.BestContactNumber = CurrentHouse.PhoneNumber;
                Landlorduser.CreatedBy         = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString());
                Landlorduser.UpdatedBy         = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString());
                Landlorduser.IsPartialUser     = true;
                Landlorduser.RoleId            = aspnet_Roles_.RoleId;
                Landlorduser.UpdatedDate       = DateTime.Now;

                if (Landlorduser.Save())
                {
                    landload.user           = Landlorduser;
                    landload.LandlordId     = Landlorduser.UserId.Value;
                    landload.LandlordName   = Landlorduser.FirstName;
                    landload.IsDeleted      = false;
                    landload.LandlordTypeId = (int)Enums.LandlordType.CorporateLandlord;
                    landload.CreatedBy      = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString());
                    landload.UpdatedBy      = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString());

                    if (landload.Save())
                    {
                        //Todo: Update the basehouse table with the new LandlordId
                        CurrentHouse.LandlordId = landlordId;
                        CurrentHouse.CreatedBy  = Membership.GetUser().UserName;
                        CurrentHouse.UpdatedBy  = Membership.GetUser().UserName;
                        if (CurrentHouse.Save())
                        {
                            //Base House is updated with new landlord id
                        }
                    }
                }
            }
            return(landlordId);
        }
コード例 #6
0
        //
        // GET: /aspnet_RolesAdmin/Details/5

        public ActionResult Details(Guid?id)
        {
            aspnet_Roles aspnet_roles = db.aspnet_Roles.Find(id);

            if (aspnet_roles == null)
            {
                return(HttpNotFound());
            }
            return(View(aspnet_roles));
        }
コード例 #7
0
 // Default contructor that set entity to field
 public aspnet_RolesModel(aspnet_Roles aspnet_roles)
 {
     this._aspnet___roles       = aspnet_roles;
     this._application_id       = aspnet_roles.ApplicationId;
     this._role_id              = aspnet_roles.RoleId;
     this._role_name            = aspnet_roles.RoleName;
     this._lowered_role_name    = aspnet_roles.LoweredRoleName;
     this._description          = aspnet_roles.Description;
     this._originalaspnet_Roles = aspnet_roles.DeepClone();
 }
コード例 #8
0
 public ActionResult Edit(aspnet_Roles aspnet_roles)
 {
     if (ModelState.IsValid)
     {
         db.Entry(aspnet_roles).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(aspnet_roles));
 }
コード例 #9
0
        public bool SaveLandload()
        {
            bool         result        = true;
            aspnet_Roles aspnet_Roles_ = new aspnet_Roles();

            Landlord landload = new Landlord();

            aspnet_Roles_ = aspnet_Roles.Select("landlord");

            User Landlorduser = new User();

            if (hdLandloadId.Value != null && hdLandloadId.Value != string.Empty)
            {
                Landlorduser.UserId            = Guid.Parse(hdLandloadId.Value);
                Landlorduser.PersonalEmail     = LandloadEmail.Text.Trim();
                Landlorduser.FirstName         = LandloadFirstName.Text.Trim();
                Landlorduser.MiddleName        = LandloadMiddleName.Text.Trim();
                Landlorduser.LastName          = LandloadLastName.Text.Trim();
                Landlorduser.BestContactNumber = LandloadMobileArea.Text.Trim() + LandloadMobile1.Text.Trim() + LandloadMobile2.Text.Trim();//Mobile.Text.Trim();
                Landlorduser.CreatedBy         = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString());
                Landlorduser.UpdatedBy         = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString());
                Landlorduser.IsPartialUser     = true;
                Landlorduser.RoleId            = aspnet_Roles_.RoleId;
                Landlorduser.UpdatedDate       = DateTime.Now;

                if (Landlorduser.Save())
                {
                    landload.user         = Landlorduser;
                    landload.LandlordId   = Landlorduser.UserId.HasValue ? Landlorduser.UserId.Value : Landlorduser.UserId.Value;
                    landload.LandlordName = Landlorduser.FirstName + " " + Landlorduser.MiddleName + " " + Landlorduser.LastName;

                    landload.CreatedBy = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString());
                    landload.UpdatedBy = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString());
                    result             = landload.Save();

                    string strMsgContent = Landloadmessage(Landlorduser.UserId.Value, Landlorduser);

                    string strMsgTitle = SystemConfig.GetValue(RHP.Common.Enums.SystemConfig.SITEURL) + " is Requesting you to join with Us.";

                    int rtn = LandloadSendEmail(Landlorduser.PersonalEmail, strMsgTitle, strMsgContent);


                    if (rtn == 1)
                    {
                    }
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "Redirect", "window.onload = function(){ alert('" + Messages.Save_Success + "'); window.location = '/Student/Student_Profile_Update_Current_House.aspx';}", true);
                }
            }
            else
            {
                LandloadLabelmessage.Text = "Landlord Details cannot saved.Please try again!";
                // no  Landload id
            }
            return(result);
        }
コード例 #10
0
        /// <summary>
        /// Get role from database. Throws an error if the role could not be found.
        /// </summary>
        /// <param name="query">The role query.</param>
        /// <param name="context">The context.</param>
        /// <returns>Found role entity.</returns>
        private aspnet_Roles GetRole(Expression <Func <aspnet_Roles, bool> > query, InventoryManagementEntities context)
        {
            aspnet_Roles role = context.aspnet_Roles.Where(query).Where(MatchRoleApplication()).FirstOrDefault();

            if (role == null)
            {
                throw new ProviderException("The supplied role name could not be found.");
            }

            return(role);
        }
コード例 #11
0
        public ActionResult Create(aspnet_Roles aspnet_roles)
        {
            if (ModelState.IsValid)
            {
                aspnet_roles.RoleId = Guid.NewGuid();
                db.aspnet_Roles.Add(aspnet_roles);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(aspnet_roles));
        }
コード例 #12
0
        public List <string> RetrieveAllUserRoles(Guid UserId)
        {
            var           rolelist    = ent.vw_aspnet_UsersInRoles.Where(xx => xx.UserId == UserId).ToList();
            List <string> AllroleList = new List <string>();

            foreach (var role in rolelist)
            {
                aspnet_Roles individualrole = GetRoleInfoByName(GETRolename(role.RoleId));
                AllroleList.Add(individualrole.RoleName);
            }
            return(AllroleList);
        }
コード例 #13
0
        public bool Save()
        {
            bool         result        = true;
            aspnet_Roles aspnet_Roles_ = new aspnet_Roles();

            aspnet_Roles_ = aspnet_Roles.Select("landlord");

            User Landlorduser = new User();

            if (LandlordId == null)
            {
                Landlorduser.UserId            = Guid.NewGuid();
                Landlorduser.PersonalEmail     = Email.Text.Trim();
                Landlorduser.FirstName         = FirstName.Text.Trim();
                Landlorduser.MiddleName        = MiddleName.Text.Trim();
                Landlorduser.LastName          = LastName.Text.Trim();
                Landlorduser.BestContactNumber = MobileArea.Text.Trim() + Mobile1.Text.Trim() + Mobile2.Text.Trim();//Mobile.Text.Trim();
                Landlorduser.CreatedBy         = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString());
                Landlorduser.UpdatedBy         = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString());
                Landlorduser.IsPartialUser     = true;
                Landlorduser.RoleId            = aspnet_Roles_.RoleId;

                if (Landlorduser.Save())
                {
                    landload.user         = Landlorduser;
                    landload.LandlordId   = Landlorduser.UserId.HasValue ? Landlorduser.UserId.Value : Landlorduser.UserId.Value;
                    LandlordId            = landload.LandlordId;//setting value of property
                    landload.LandlordName = Landlorduser.FirstName + " " + Landlorduser.MiddleName + " " + Landlorduser.LastName;

                    landload.CreatedBy = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString());
                    landload.UpdatedBy = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString());
                    result             = landload.Save();

                    string strMsgContent = message(Landlorduser.UserId.Value, Landlorduser);

                    string strMsgTitle = RHP.Common.Enums.SystemConfig.SITEURL + " is Requesting you to join with Us.";

                    int rtn = SendEmail(Landlorduser.PersonalEmail, strMsgTitle, strMsgContent);

                    if (rtn == 1)
                    {
                    }
                }

                LandlordId = Landlorduser.UserId;
            }
            else
            {
                // Landload already registerd
            }
            return(result);
        }
コード例 #14
0
        /// <summary>
        /// Gets a list of users in the specified role for the configured applicationName.
        /// </summary>
        /// <param name="roleName">The name of the role to get the list of users for.</param>
        /// <returns>
        /// A string array containing the names of all the users who are members of the specified role for the configured applicationName.
        /// </returns>
        public override string[] GetUsersInRole(string roleName)
        {
            using (InventoryManagementEntities context = new InventoryManagementEntities())
            {
                aspnet_Roles role = GetRole(r => r.RoleName == roleName, context);
                if (role == null)
                {
                    throw new ProviderException("Role not found.");
                }

                return(role.aspnet_Users.Select(u => u.UserName).ToArray());
            }
        }
        public RoleAuthenticationModel GetRole(string roleName)
        {
            RoleAuthenticationModel e    = new RoleAuthenticationModel();
            aspnet_Roles            role = DB.aspnet_Roles.Where(r => r.RoleName == roleName).FirstOrDefault();

            if (role != null)
            {
                List <int?> controllerActionIDList = role.MVCAuthorizations.Select(r => r.ControllerActionID).ToList();
                e.RoleName = role.RoleName;
                e.ControllerActionIDList = controllerActionIDList;
            }
            return(e);
        }
コード例 #16
0
 public void InsertRoleDescByRoleName(String roleName, String roleDesc)
 {
     using (DockerDBEntities dockerEntities = new DockerDBEntities()) {
         aspnet_Roles role = (from p in dockerEntities.aspnet_Roles
                              where p.RoleName == roleName
                              select p).First();
         if (role != null)
         {
             role.Description = roleDesc;
         }
         dockerEntities.SaveChanges();
     }
 }
コード例 #17
0
        /// <summary>
        /// Gets an array of user names in a role where the user name contains the specified user name to match.
        /// </summary>
        /// <returns>A string array containing the names of all the users where the user name matches <paramref name="usernameToMatch" />
        /// and the user is a member of the specified role.</returns>
        /// <param name="roleName">The role to search in.</param>
        /// <param name="usernameToMatch">The user name to search for.</param>
        public override string[] FindUsersInRole(string roleName, string usernameToMatch)
        {
            using (InventoryManagementEntities context = new InventoryManagementEntities())
            {
                aspnet_Roles role = GetRole(r => r.RoleName == roleName, context);
                if (role == null)
                {
                    throw new ProviderException("Role not found.");
                }


                return(role.aspnet_Users.Where(u => u.aspnet_Membership.IsLockedOut != false).Select(u => u.UserName).Where(un => un.Contains(usernameToMatch)).ToArray());
            }
        }
コード例 #18
0
        public bool Save()
        {
            bool result = true;

            aspnet_Roles aspnet_Roles_ = new aspnet_Roles();

            aspnet_Roles_ = aspnet_Roles.Select("student");

            User user_ = new User();

            foreach (GridViewRow row in GridviewRoommatelist.Rows)
            {
                user_.PersonalEmail     = string.IsNullOrEmpty(row.Cells[1].Text.Trim()) ? string.Empty : row.Cells[1].Text.Trim();
                user_.FirstName         = string.IsNullOrEmpty(row.Cells[2].Text.Trim()) ? string.Empty : row.Cells[2].Text.Trim();
                user_.MiddleName        = string.IsNullOrEmpty(row.Cells[3].Text.Trim()) ? string.Empty : row.Cells[3].Text.Trim();
                user_.MiddleName        = user_.MiddleName.Replace("&nbsp;", "");
                user_.LastName          = string.IsNullOrEmpty(row.Cells[4].Text.Trim()) ? string.Empty : row.Cells[4].Text.Trim();
                user_.BestContactNumber = string.IsNullOrEmpty(row.Cells[5].Text.Trim()) ? string.Empty : row.Cells[5].Text.Trim();

                user_.UserId        = Guid.NewGuid();
                user_.CreatedBy     = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString());
                user_.UpdatedBy     = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString());
                user_.IsPartialUser = true;
                user_.HouseId       = HouseId.Value;
                user_.RoleId        = aspnet_Roles_.RoleId;

                if (result = user_.Save())
                {
                    Save_Student_House(user_);

                    string strMsgContent = message(user_.UserId.Value, user_);

                    string strMsgTitle = SystemConfig.GetValue(RHP.Common.Enums.SystemConfig.SITEURL) + "  is Requesting you to join with Us.";

                    int rtn = SendEmail(user_.PersonalEmail, strMsgTitle, strMsgContent);

                    if (rtn == 1)
                    {
                    }
                }
            }

            if (result)
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "Redirect", "window.onload = function(){ alert('" + Messages.Save_Success + "'); window.location = '/Student/Student_Profile.aspx';}", true);
            }
            return(result);
        }
コード例 #19
0
ファイル: DocumentsOperations.cs プロジェクト: qiugs/dms
 public void InsertRolesFilesAuthorizations(Guid roleID, Guid fileID)
 {
     using (DockerDBEntities dockerEntities = new DockerDBEntities()) {
         File file = (from p in dockerEntities.Files
                      where p.ID == fileID
                      select p).First();
         aspnet_Roles role = (from p in dockerEntities.aspnet_Roles
                              where p.RoleId == roleID
                              select p).First();
         if (!file.aspnet_Roles.Contains(role))
         {
             file.aspnet_Roles.Add(role);
             dockerEntities.SaveChanges();
         }
     }
 }
コード例 #20
0
ファイル: DocumentsOperations.cs プロジェクト: qiugs/dms
 public void RemoveRolesFilesAuthorizations(Guid roleID, Guid fileID)
 {
     using (DockerDBEntities dockerEntities = new DockerDBEntities()) {
         aspnet_Roles role = (from p in dockerEntities.aspnet_Roles
                              where p.RoleId == roleID
                              select p).First();
         foreach (File file in role.Files.ToList())
         {
             if (file.ID == fileID)
             {
                 role.Files.Remove(file); break;
             }
         }
         dockerEntities.SaveChanges();
     }
 }
コード例 #21
0
ファイル: DocumentsOperations.cs プロジェクト: qiugs/dms
 public void RemoveRolesFilesAuthorizationsByRoleID(Guid roleID)
 {
     using (DockerDBEntities dockerEntities = new DockerDBEntities()) {
         aspnet_Roles role = (from p in dockerEntities.aspnet_Roles
                              where p.RoleId == roleID
                              select p).First();
         foreach (File file in role.Files.ToList())
         {
             role.Files.Remove(file);
         }
         foreach (FeatureAccessProfile fap in role.FeatureAccessProfiles.ToList())
         {
             role.FeatureAccessProfiles.Remove(fap);
         }
         dockerEntities.SaveChanges();
     }
 }
コード例 #22
0
        private void addRole(aspnet_Roles role)
        {
            aspnet_Roles oldrole = Uow.aspnet_Roles.GetAll().FirstOrDefault(r => r.RoleName == role.RoleName);

            if (oldrole != null)
            {
                throw new BusinessException(role.RoleName + "角色已存在");
            }
            RoleService.Create(role.RoleName);
            aspnet_Roles oldrole2 = Uow.aspnet_Roles.GetAll().FirstOrDefault(r => r.RoleName == role.RoleName);

            if (oldrole2 != null)
            {
                oldrole2.Description = role.Description;
                Uow.aspnet_Roles.Update(oldrole2);
                Uow.Commit();
            }
        }
コード例 #23
0
        public bool SaveNewstudent()
        {
            bool result = true;

            aspnet_Roles aspnet_Roles_ = new aspnet_Roles();

            aspnet_Roles_ = aspnet_Roles.Select("student");

            User user_ = new User();

            user_.PersonalEmail     = Email.Text.Trim();
            user_.FirstName         = FirstName.Text.Trim();
            user_.MiddleName        = MiddleName.Text.Trim();
            user_.LastName          = LastName.Text.Trim();
            user_.BestContactNumber = MobileArea.Text.Trim() + Mobile1.Text.Trim() + Mobile2.Text.Trim();

            user_.UserId        = Guid.NewGuid();
            user_.CreatedBy     = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString());
            user_.UpdatedBy     = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString());
            user_.IsPartialUser = true;
            user_.HouseId       = Guid.Parse(hdHouseId.Value);
            user_.RoleId        = aspnet_Roles_.RoleId;

            if (result = user_.Save())
            {
                Save_Student_House(user_);

                string strMsgContent = message(user_.UserId.Value, user_);

                string strMsgTitle = "www.ratemystudenthome.com is Requesting you to join with Us.";

                int rtn = SendEmail(user_.PersonalEmail, strMsgTitle, strMsgContent);

                if (rtn == 1)
                {
                }
            }

            if (result)
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "Redirect", "window.onload = function(){ alert('" + Messages.Save_Success + "'); window.location = '/Student/Student_Profile.aspx';}", true);
            }
            return(result);
        }
コード例 #24
0
ファイル: AccountModels.cs プロジェクト: manish-sf/Vedanta
        public static bool AssignRoleToUser(RegisterModel model)
        {
            using (Vedanta.Models.VedantaEntities ve = new Vedanta.Models.VedantaEntities())
            {
                aspnet_Users old_User = ve.aspnet_Users.FirstOrDefault(usr => usr.UserName == model.UserName);
                if (old_User != null)
                {
                    MembershipUser memUser = Membership.GetUser(model.UserName);

                    aspnet_Roles role = ve.aspnet_Roles.FirstOrDefault(r => r.RoleId == model.UserRole);
                    if (role != null)
                    {
                        Roles.AddUserToRole(memUser.UserName, role.RoleName);
                        if (memUser != null)
                        {
                            int branchId = 0;
                            if (!string.IsNullOrEmpty(model.EmployeeId))
                            {
                                Employees emp = new Employees();
                                emp = ve.Employees.FirstOrDefault(e => model.EmployeeId.Equals(e.EmployeeId, StringComparison.OrdinalIgnoreCase));
                                if (emp != null)
                                {
                                    branchId = emp.BranchId ?? 0;
                                }
                            }
                            associated_Users a_user = new associated_Users();
                            a_user.Membership_UserId = (Guid)memUser.ProviderUserKey;
                            a_user.EmployeeId        = model.EmployeeId;
                            a_user.ClientId          = model.ClientId;
                            a_user.BranchId          = branchId;
                            ve.AddToassociated_Users(a_user);
                            if (ve.SaveChanges() > 0)
                            {
                                return(true);
                            }
                        }
                        return(true);
                    }
                }
            }

            return(false);
        }
コード例 #25
0
        /// <summary>
        /// Adds a new role to the data source for the configured applicationName.
        /// </summary>
        /// <param name="roleName">The name of the role to create.</param>
        public override void CreateRole(string roleName)
        {
            // Validate role name
            if (roleName.Contains(","))
            {
                throw new ArgumentException("Role names cannot contain commas.");
            }

            if (RoleExists(roleName))
            {
                throw new ProviderException("Role name already exists.");
            }

            try
            {
                using (InventoryManagementEntities context = new InventoryManagementEntities())
                {
                    aspnet_Applications application = ProviderUtils.EnsureApplication(ApplicationName, context);

                    // Create new role
                    aspnet_Roles newRole = new aspnet_Roles
                    {
                        RoleId          = Guid.NewGuid(),
                        RoleName        = roleName,
                        LoweredRoleName = roleName.ToLower(),
                        ApplicationId   = application.ApplicationId
                    };
                    context.aspnet_Roles.Add(newRole);
                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                if (WriteExceptionsToEventLog)
                {
                    WriteToEventLog(ex, "CreateRole");
                }
                else
                {
                    throw;
                }
            }
        }
コード例 #26
0
        public bool Save()
        {
            bool result = true;

            aspnet_Roles aspnet_Roles_ = new aspnet_Roles();

            aspnet_Roles_ = aspnet_Roles.Select("student");

            User user_ = new User();

            user_ = RHP.UserManagement.User.Select(Guid.Parse(hdUserID.Value));

            user_.PersonalEmail     = Email.Text.Trim();
            user_.FirstName         = FirstName.Text.Trim();
            user_.MiddleName        = MiddleName.Text.Trim();
            user_.LastName          = LastName.Text.Trim();
            user_.BestContactNumber = MobileArea.Text.Trim() + Mobile1.Text.Trim() + Mobile2.Text.Trim();

            user_.CreatedBy = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString());
            user_.UpdatedBy = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString());

            if (result = user_.Save())
            {
                string strMsgContent = message(user_.UserId.Value, user_);

                string strMsgTitle = SystemConfig.GetValue(RHP.Common.Enums.SystemConfig.SITEURL) + " is Requesting you to join with Us.";

                int rtn = SendEmail(user_.PersonalEmail, strMsgTitle, strMsgContent);

                if (rtn == 1)
                {
                }
            }


            if (result)
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "Redirect", "window.onload = function(){ alert('" + Messages.Save_Success + "'); window.location = '/Student/Student_Profile.aspx';}", true);
            }
            return(result);
        }
コード例 #27
0
        /// <summary>
        /// Removes a role from the data source for the configured applicationName.
        /// </summary>
        /// <param name="roleName">The name of the role to delete.</param>
        /// <param name="throwOnPopulatedRole">If true, throw an exception if <paramref name="roleName"/> has one or more members and do not delete <paramref name="roleName"/>.</param>
        /// <returns>
        /// true if the role was successfully deleted; otherwise, false.
        /// </returns>
        public override bool DeleteRole(string roleName, bool throwOnPopulatedRole)
        {
            // Validate role
            if (!RoleExists(roleName))
            {
                throw new ProviderException("Role does not exist.");
            }

            if (throwOnPopulatedRole && GetUsersInRole(roleName).Length > 0)
            {
                throw new ProviderException("Cannot delete a populated role.");
            }

            using (InventoryManagementEntities context = new InventoryManagementEntities())
            {
                aspnet_Roles role = GetRole(r => r.RoleName == roleName, context);
                if (role == null)
                {
                    return(false);
                }

                try
                {
                    context.aspnet_Roles.Remove(role);
                    context.SaveChanges();
                }
                catch (Exception ex)
                {
                    if (WriteExceptionsToEventLog)
                    {
                        WriteToEventLog(ex, "DeleteRole");
                        return(false);
                    }

                    throw;
                }

                return(true);
            }
        }
コード例 #28
0
 /// <summary>
 /// There are no comments for aspnet_Roles in the schema.
 /// </summary>
 public void AddToaspnet_Roles(aspnet_Roles aspnet_Roles)
 {
     base.AddObject("aspnet_Roles", aspnet_Roles);
 }
コード例 #29
0
 /// <summary>
 /// Create a new aspnet_Roles object.
 /// </summary>
 /// <param name="roleId">Initial value of RoleId.</param>
 /// <param name="roleName">Initial value of RoleName.</param>
 /// <param name="loweredRoleName">Initial value of LoweredRoleName.</param>
 public static aspnet_Roles Createaspnet_Roles(global::System.Guid roleId, string roleName, string loweredRoleName)
 {
     aspnet_Roles aspnet_Roles = new aspnet_Roles();
     aspnet_Roles.RoleId = roleId;
     aspnet_Roles.RoleName = roleName;
     aspnet_Roles.LoweredRoleName = loweredRoleName;
     return aspnet_Roles;
 }
コード例 #30
0
        public Guid GetIdbyRolename(string rolename)
        {
            aspnet_Roles roles = GetRoleInfoByName(rolename);

            return(roles.RoleId);
        }
コード例 #31
0
        public string Rolename(Guid roleid)
        {
            aspnet_Roles roles = GetRoleInfo(roleid);

            return(roles.RoleName);
        }
コード例 #32
0
        protected void CreateUserButton_Click(object sender, EventArgs e)
        {
            if (Page.IsValid == true)
            {
                ShowPartialUserEmailRequest.Visible = false;
                try
                {
                    bool boolMembershipUserCreated = false;

                    string AccessCode = Utility.GetQueryStringValueByKey(Request, "ActivationKey");

                    if (AccessCode != string.Empty && AccessCode != null)
                    {
                        user = User.Select(Guid.Parse(AccessCode));
                    }

                    bool PartialEmail = false;

                    if (user.IsPartialUser == false)
                    {
                        PartialEmail = checkPartialEmail();
                    }

                    if (PartialEmail == false)
                    {
                        user.Email         = Email.Text.Trim();
                        user.Status        = "Active";
                        user.PersonalEmail = Email.Text.Trim();
                        user.Password      = Password.Text.Trim();
                        user.UserName      = UserName.Text.Trim();
                        user.Question      = Question.Text.Trim();
                        user.Answer        = Answer.Text.Trim();

                        aspnet_Roles aspnet_Roles_ = new aspnet_Roles();
                        aspnet_Roles_ = aspnet_Roles.Select("landlord");

                        user.FirstName    = FirstName.Text.Trim();
                        user.MiddleName   = MiddleName.Text.Trim();
                        user.LastName     = LastName.Text.Trim();
                        user.RoleId       = aspnet_Roles_.RoleId;
                        user.ReferralCode = ReferralCode.Text.Trim();

                        object objCreateMembershipUser = new object();

                        bool IsActivate = false;


                        if (SystemConfig.GetValue(Enums.SystemConfig.IsEmailActivation).ToLower() == "true")
                        {
                            IsActivate = false;
                        }
                        else
                        {
                            IsActivate = true;
                        }

                        if (user.IsPartialUser)
                        {
                            objCreateMembershipUser = user.AddMembershipPartialUser(user.UserName, user.Password, user.Email, user.Question, user.Answer, IsActivate, user.UserId.Value, "landlord");
                        }
                        else
                        {
                            objCreateMembershipUser = user.AddMembershipUser(user.UserName, user.Password, user.Email, user.Question, user.Answer, IsActivate, "landlord");
                        }

                        bool.TryParse(objCreateMembershipUser.ToString(), out boolMembershipUserCreated);

                        if (boolMembershipUserCreated)
                        {
                            Session[Constants.SESSION_LOGGED_USER] = user;

                            MembershipUser newUser = Membership.GetUser(user.UserName);
                            user.UserId       = Guid.Parse(newUser.ProviderUserKey.ToString());
                            user.AspnetUserId = Guid.Parse(newUser.ProviderUserKey.ToString());
                            user.CreatedBy    = Guid.Parse(newUser.ProviderUserKey.ToString());
                            user.UpdatedBy    = Guid.Parse(newUser.ProviderUserKey.ToString());

                            if (user.Save())
                            {
                                landload.LandlordId   = user.UserId.HasValue ? user.UserId.Value : Guid.Parse(Membership.GetUser().ProviderUserKey.ToString());
                                landload.LandlordName = user.FirstName + " " + user.MiddleName + " " + user.LastName;
                                landload.user         = user;
                                landload.CreatedBy    = Guid.Parse(newUser.ProviderUserKey.ToString());
                                landload.UpdatedBy    = Guid.Parse(newUser.ProviderUserKey.ToString());

                                if (landload.Save())
                                {
                                }
                            }
                            if (SystemConfig.GetValue(Enums.SystemConfig.IsEmailActivation).ToLower() == "true")
                            {
                                string strMsgContent = message((Guid)newUser.ProviderUserKey);

                                string strMsgTitle = SystemConfig.GetValue(RHP.Common.Enums.SystemConfig.SITEURL) + "- Action required for account activation.";

                                int rtn = SendEmail(user.Email, strMsgTitle, strMsgContent);

                                if (rtn == 1)
                                {
                                    Page.ClientScript.RegisterStartupScript(this.GetType(), "Redirect", "window.onload = function(){ alert('" + Messages.Create_Account_Success + "'); window.location = '/Login.aspx?type=l'; }", true);
                                }
                                else
                                {
                                    Page.ClientScript.RegisterStartupScript(this.GetType(), "Redirect", "window.onload = function(){ alert('" + Messages.Sending_Email_Error + "'); window.location = '/Login.aspx?type=l'; }", true);
                                }
                                // success
                            }
                            else
                            {
                                Page.ClientScript.RegisterStartupScript(this.GetType(), "Redirect", "window.onload = function(){ alert('" + Messages.Create_Account_Success + "'); window.location = '/Login.aspx?type=l'; }", true);
                            }
                        }
                        else
                        {
                            Page.ClientScript.RegisterStartupScript(this.GetType(), "Redirect", "window.onload = function(){ alert('" + Messages.Profile_Create_Unsuccess + " - " + objCreateMembershipUser.ToString() + "'); }", true);
                        }
                    }
                    else
                    {
                        User user_check = new User();

                        if (user_check.IsPartialUserEmailExist(Email.Text.Trim().ToLower()))
                        {
                            ShowfullRegistration.Visible        = false;
                            ShowPartialUserEmailRequest.Visible = true;
                            lblpartialuserEmail.Text            = Email.Text.Trim();
                            lblpartialuserEmail2.Text           = Email.Text.Trim();
                        }
                        else
                        {
                            Page.ClientScript.RegisterStartupScript(this.GetType(), "Redirect", "window.onload = function(){ alert('" + Messages.Profile_Create_Unsuccess + " - " + Messages.EmailAddressExist + "'); }", true);
                            ShowPartialUserEmailRequest.Visible = false;
                            ShowfullRegistration.Visible        = true;
                        }
                    }
                }
                catch (Exception ex)
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "Redirect", "window.onload = function(){ alert('" + Messages.Profile_Create_Unsuccess + "'); }", true);

                    // throw new Exception("LandLord Profile info : " + ex.ToString());
                }
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "Redirect", "window.onload = function(){ alert('" + Messages.Validation_Fail + "'); }", true);
            }
        }
コード例 #33
0
 /// <summary>
 /// Create a new aspnet_Roles object.
 /// </summary>
 /// <param name="roleId">Initial value of RoleId.</param>
 /// <param name="roleName">Initial value of RoleName.</param>
 /// <param name="loweredRoleName">Initial value of LoweredRoleName.</param>
 /// <param name="applicationId">Initial value of ApplicationId.</param>
 public static aspnet_Roles Createaspnet_Roles(string roleId, string roleName, string loweredRoleName, string applicationId)
 {
     aspnet_Roles aspnet_Roles = new aspnet_Roles();
     aspnet_Roles.RoleId = roleId;
     aspnet_Roles.RoleName = roleName;
     aspnet_Roles.LoweredRoleName = loweredRoleName;
     aspnet_Roles.ApplicationId = applicationId;
     return aspnet_Roles;
 }