コード例 #1
0
        public async Task <int> CreateAsync(AdminMenuCreateCommand request, CancellationToken cancellationToken)
        {
            var entity = mapper.Map <AdminMenuCreateCommand, AdminMenuEntity>(request);

            var res = await db.AddAsync(entity, cancellationToken : cancellationToken);

            if (res > 0)
            {
                return(res);
            }
            else
            {
                return(res);
            }
        }
コード例 #2
0
            public override async Task <int> Handle(AdminUserRelevanceRoleCommand request, CancellationToken cancellationToken)
            {
                //先清空用户的角色,确保没有冗余的数据
                await db.DeleteAsync <AdminUserRoleEntity>(c => c.AdminId == request.AdminId);

                var userRoles = Array.ConvertAll(request.RoleIds, roleid => new AdminUserRoleEntity
                {
                    RoleId  = roleid,
                    AdminId = request.AdminId
                });

                //添加角色
                if (userRoles.Length > 0)
                {
                    return(await db.AddAsync(userRoles));
                }

                return(1);
            }