コード例 #1
0
        public async Task <bool> Insert(RoleModelAdd role)
        {
            var roleEntity = _mapper.Map <Role>(role);

            role.Permissions.ForEach(x =>
            {
                roleEntity.RolePermissionRelationship.Add(new RolePermissionRelationship
                {
                    PermissionId = x
                });
            });

            _context.Role.Add(roleEntity);
            var result = await _context.SaveChangesAsync() > 0;

            return(result);
        }
コード例 #2
0
        public async Task <bool> Insert(PermissionModelAdd permissionModelAdd)
        {
            var permissionEntity = _mapper.Map <Permission>(permissionModelAdd);

            _context.Permission.Add(permissionEntity);
            var result = await _context.SaveChangesAsync() > 0;

            return(result);
        }
コード例 #3
0
        public async Task <bool> Insert(UserModelAdd user)
        {
            var userEntity = _mapper.Map <User>(user);

            if (user.RoleIds.Count() > 0)
            {
                user.RoleIds.ForEach(x =>
                {
                    userEntity.UserRoleRelationship.Add(new UserRoleRelationship
                    {
                        RoleId = x
                    });
                });
            }

            _context.User.Add(userEntity);

            var result = await _context.SaveChangesAsync() > 0;

            return(result);
        }