Exemplo n.º 1
0
        protected void btnSubmit_OnClick(object sender, EventArgs e)
        {
            var userGroup = new CloneDeployUserGroupEntity
            {
                Name        = txtGroupName.Text,
                Membership  = ddlGroupMembership.Text,
                IsLdapGroup = chkldap.Checked ? 1 : 0
            };

            if (chkldap.Checked)
            {
                userGroup.GroupLdapName = txtLdapGroupName.Text;
            }

            var result = Call.UserGroupApi.Post(userGroup);

            if (!result.Success)
            {
                EndUserMessage = result.ErrorMessage;
            }
            else
            {
                EndUserMessage = "Successfully Created User Group";
                Response.Redirect("~/views/users/editgroup.aspx?groupid=" + result.Id);
            }
        }
Exemplo n.º 2
0
        private ValidationResultDTO ValidateUserGroup(CloneDeployUserGroupEntity userGroup, bool isNewUserGroup)
        {
            var validationResult = new ValidationResultDTO {
                Success = true
            };

            if (isNewUserGroup)
            {
                if (_uow.UserGroupRepository.Exists(h => h.Name == userGroup.Name))
                {
                    validationResult.Success      = false;
                    validationResult.ErrorMessage = "This User Group Already Exists";
                    return(validationResult);
                }
            }
            else
            {
                var originalUserGroup = _uow.UserGroupRepository.GetById(userGroup.Id);
                if (originalUserGroup.Name != userGroup.Name)
                {
                    if (_uow.UserGroupRepository.Exists(h => h.Name == userGroup.Name))
                    {
                        validationResult.Success      = false;
                        validationResult.ErrorMessage = "This User Group Already Exists";
                        return(validationResult);
                    }
                }
            }

            return(validationResult);
        }
Exemplo n.º 3
0
        public ActionResultDTO UpdateUserGroup(CloneDeployUserGroupEntity userGroup)
        {
            var ug = GetUserGroup(userGroup.Id);

            if (ug == null)
            {
                return new ActionResultDTO {
                           ErrorMessage = "User Group Not Found", Id = 0
                }
            }
            ;
            var actionResult     = new ActionResultDTO();
            var validationResult = ValidateUserGroup(userGroup, false);

            if (validationResult.Success)
            {
                _uow.UserGroupRepository.Update(userGroup, userGroup.Id);

                _uow.Save();
                actionResult.Success = true;
                actionResult.Id      = userGroup.Id;
            }
            else
            {
                actionResult.ErrorMessage = validationResult.ErrorMessage;
            }

            return(actionResult);
        }
Exemplo n.º 4
0
        public ActionResultDTO Put(int id, CloneDeployUserGroupEntity userGroup)
        {
            userGroup.Id = id;
            var result = _userGroupServices.UpdateUserGroup(userGroup);

            if (result == null)
            {
                throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound));
            }
            return(result);
        }
Exemplo n.º 5
0
 protected override void OnInit(EventArgs e)
 {
     base.OnInit(e);
     CloneDeployUser = !string.IsNullOrEmpty(Request["userid"])
         ? Call.CloneDeployUserApi.Get(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"])
         ? Call.UserGroupApi.Get(Convert.ToInt32(Request.QueryString["groupid"]))
         : null;
 }
Exemplo n.º 6
0
        public ActionResultDTO Put(int id, CloneDeployUserGroupEntity tObject)
        {
            Request.Method = Method.PUT;
            Request.AddJsonBody(tObject);
            Request.Resource = string.Format("api/{0}/Put/{1}", Resource, id);
            var response = _apiRequest.Execute <ActionResultDTO>(Request);

            if (response.Id == 0)
            {
                response.Success = false;
            }
            return(response);
        }
Exemplo n.º 7
0
        public ActionResultDTO AddUserGroup(CloneDeployUserGroupEntity userGroup)
        {
            var validationResult = ValidateUserGroup(userGroup, true);
            var actionResult     = new ActionResultDTO();

            if (validationResult.Success)
            {
                _uow.UserGroupRepository.Insert(userGroup);
                _uow.Save();
                actionResult.Success = true;
                actionResult.Id      = userGroup.Id;
            }
            else
            {
                actionResult.ErrorMessage = validationResult.ErrorMessage;
            }

            return(actionResult);
        }
Exemplo n.º 8
0
 public ActionResultDTO Post(CloneDeployUserGroupEntity userGroup)
 {
     return(_userGroupServices.AddUserGroup(userGroup));
 }