예제 #1
0
        /// <summary>
        /// 为岗位添加功能
        /// </summary>
        /// <param name="roleid"></param>
        /// <param name="rightid"></param>
        public void RelationRigths(int roleid, string[] rightid)
        {
            Role model = this.GetRole(roleid);

            if (model == null)
            {
                throw new EntityIsInvalidException <string>(roleid.ToString());
            }
            model.Rights.Clear();
            IEnumerable <Rights> list = this._rightsService.GetRights(rightid);

            model.AddRights(list);
            this._uow.Commit();
        }
예제 #2
0
        public RoleView AddRole(int organizationid, string name, string description, string rightsIds)
        {
            string[]     rightsIdList = rightsIds.Split('|');
            Organization orgmodel     = this._organizationRepository.FindBy(organizationid);

            if (orgmodel == null)
            {
                throw new EntityIsInvalidException <string>(organizationid.ToString());
            }

            Role model = new Role(orgmodel, name, description);
            IEnumerable <Rights> rightslList = this._rightsService.GetRightsByIdList(rightsIdList);

            model.AddRights(rightslList);

            this._roleRepository.Add(model);
            this._uow.Commit();
            return(model.ConvertToRoleView());
        }