Ejemplo n.º 1
0
        public static Models.ValidationResult ValidateUser(Models.CloneDeployUserGroup userGroup, bool isNewUserGroup)
        {
            var validationResult = new Models.ValidationResult();

            if (isNewUserGroup)
            {
                using (var uow = new DAL.UnitOfWork())
                {
                    if (uow.UserGroupRepository.Exists(h => h.Name == userGroup.Name))
                    {
                        validationResult.IsValid = false;
                        validationResult.Message = "This User Group Already Exists";
                        return(validationResult);
                    }
                }
            }
            else
            {
                using (var uow = new DAL.UnitOfWork())
                {
                    var originalUserGroup = uow.UserGroupRepository.GetById(userGroup.Id);
                    if (originalUserGroup.Name != userGroup.Name)
                    {
                        if (uow.UserGroupRepository.Exists(h => h.Name == userGroup.Name))
                        {
                            validationResult.IsValid = false;
                            validationResult.Message = "This User Group Already Exists";
                            return(validationResult);
                        }
                    }
                }
            }

            return(validationResult);
        }
Ejemplo n.º 2
0
        public static void AddNewGroupMember(CloneDeployUserGroup userGroup, CloneDeployUser user)
        {
            user.Membership = userGroup.Membership;
            user.UserGroupId = userGroup.Id;
            BLL.User.UpdateUser(user);

            var rights = BLL.UserGroupRight.Get(userGroup.Id);
            var groupManagement = BLL.UserGroupGroupManagement.Get(userGroup.Id);
            var imageManagement = BLL.UserGroupImageManagement.Get(userGroup.Id);

            var userRights =
                   rights.Select(right => new Models.UserRight { UserId = user.Id, Right = right.Right }).ToList();
            BLL.UserRight.DeleteUserRights(user.Id);
            BLL.UserRight.AddUserRights(userRights);

            var userGroupManagement =
                groupManagement.Select(g => new Models.UserGroupManagement { GroupId = g.GroupId, UserId = user.Id })
                    .ToList();
            BLL.UserGroupManagement.DeleteUserGroupManagements(user.Id);
            BLL.UserGroupManagement.AddUserGroupManagements(userGroupManagement);

            var userImageManagement =
                imageManagement.Select(g => new Models.UserImageManagement { ImageId = g.ImageId, UserId = user.Id })
                    .ToList();
            BLL.UserImageManagement.DeleteUserImageManagements(user.Id);
            BLL.UserImageManagement.AddUserImageManagements(userImageManagement);
        }
Ejemplo n.º 3
0
 protected override void OnInit(EventArgs e)
 {
     base.OnInit(e);
     CloneDeployUser = !string.IsNullOrEmpty(Request["userid"]) ? BLL.User.GetUser(Convert.ToInt32(Request.QueryString["userid"])) : null;
     //Don't Check Authorization here for admin because reset pass for users won't work.
     CloneDeployUserGroup = !string.IsNullOrEmpty(Request["groupid"]) ? BLL.UserGroup.GetUserGroup(Convert.ToInt32(Request.QueryString["groupid"])) : null;
 }
Ejemplo n.º 4
0
        public static Models.ValidationResult AddUserGroup(CloneDeployUserGroup userGroup)
        {
            using (var uow = new DAL.UnitOfWork())
            {
                var validationResult = ValidateUser(userGroup, true);
                if (validationResult.IsValid)
                {
                    uow.UserGroupRepository.Insert(userGroup);
                    validationResult.IsValid = uow.Save();
                }

                return validationResult;
            }
        }
Ejemplo n.º 5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        userBasePage         = (Page as BasePages.Users);
        CloneDeployUserGroup = userBasePage.CloneDeployUserGroup;

        if (CloneDeployUserGroup == null)
        {
            Response.Redirect("~/", true);
        }

        if (CloneDeployUserGroup.Membership == "Administrator")
        {
            PageBaseMaster.EndUserMessage = "Administrators Do Not Use ACL's";
            Response.Redirect("~/views/users/editgroup.aspx?groupid=" + CloneDeployUserGroup.Id);
        }
    }
Ejemplo n.º 6
0
    protected void btnSubmit_OnClick(object sender, EventArgs e)
    {
        var userGroup = new CloneDeployUserGroup
        {
            Name = txtGroupName.Text,
            Membership = ddlGroupMembership.Text,
            IsLdapGroup = chkldap.Checked ? 1 : 0
        };
        if (chkldap.Checked)
            userGroup.GroupLdapName = txtLdapGroupName.Text;

        var result = BLL.UserGroup.AddUserGroup(userGroup);
        if (!result.IsValid)
            EndUserMessage = result.Message;
        else
        {
            EndUserMessage = "Successfully Created User Group";
            Response.Redirect("~/views/users/editgroup.aspx?groupid=" + userGroup.Id);
        }
    }
Ejemplo n.º 7
0
        public static Models.ValidationResult UpdateUser(CloneDeployUserGroup userGroup)
        {
            using (var uow = new DAL.UnitOfWork())
            {
                var validationResult = ValidateUser(userGroup, false);
                if (validationResult.IsValid)
                {
                    uow.UserGroupRepository.Update(userGroup, userGroup.Id);
                    validationResult.IsValid = uow.Save();
                }

                return validationResult;
            }
        }
Ejemplo n.º 8
0
        public static void UpdateAllGroupMembersImageMgmt(CloneDeployUserGroup userGroup)
        {
            var imageManagement = BLL.UserGroupImageManagement.Get(userGroup.Id);

            foreach (var user in GetGroupMembers(userGroup.Id))
            {
                var userImageManagement =
                    imageManagement.Select(g => new Models.UserImageManagement { ImageId = g.ImageId, UserId = user.Id })
                        .ToList();
                BLL.UserImageManagement.DeleteUserImageManagements(user.Id);
                BLL.UserImageManagement.AddUserImageManagements(userImageManagement);
            }
        }
Ejemplo n.º 9
0
        public static void UpdateAllGroupMembersAcls(CloneDeployUserGroup userGroup)
        {
            var rights = BLL.UserGroupRight.Get(userGroup.Id);

            foreach (var user in GetGroupMembers(userGroup.Id))
            {
                var userRights =
                    rights.Select(right => new Models.UserRight {UserId = user.Id, Right = right.Right}).ToList();
                BLL.UserRight.DeleteUserRights(user.Id);
                BLL.UserRight.AddUserRights(userRights);
            }
        }