Пример #1
0
        public void Add(AddRoleInput input)
        {
            input.Validate();
            Sys_Role role = this.CreateEntity <Sys_Role>();

            this.MapValueFromInput(role, input);

            string[] permissionIds = input.GetPermissionIds();
            List <Sys_RoleAuthorize> roleAuthorizeEntitys = this.CreateRoleAuthorizes(role.Id, permissionIds);

            this.DbContext.DoWithTransaction(() =>
            {
                this.DbContext.Insert(role);

                foreach (var roleAuthorizeEntity in roleAuthorizeEntitys)
                {
                    this.DbContext.Insert(roleAuthorizeEntity);
                }
            });
        }
Пример #2
0
        //[ValidateAntiForgeryToken]
        public ActionResult Add(AddRoleInput input)
        {
            input.Validate();
            var      services = CreateService <IAccountAppService>();
            Sys_Role role     = new Sys_Role();

            AceMapper.Map(input, role);
            role.CreateUserId = CurrentSession.UserId;
            role.CreateTime   = DateTime.Now;
            services.Insert(role);
            string[] permissionIds = input.GetPermissionIds();
            List <Sys_RoleAuthorize> roleAuthorizeEntitys = CreateRoleAuthorizes(role.Id, permissionIds);

            foreach (var roleAuthorizeEntity in roleAuthorizeEntitys)
            {
                services.Insert(roleAuthorizeEntity);
            }

            return(AddSuccessMsg());
        }