Exemplo n.º 1
0
        public override async Task <ChangeUserRoleResponse> ChangeUserRole(ChangeUserRoleRequest request, ServerCallContext context)
        {
            var user = await dbContext.Users.FindIfNullThrowAsync(request.UserId);

            var project = await dbContext.Projects.FindIfNullThrowAsync(request.ProjectId);

            var assignment = await dbContext.UserProjectAssignments
                             .FirstOrDefaultAsync(x => x.User == user && x.Project == project)
                             ?? throw EntityNotFoundException.Create <UserProjectAssignment>($"UserId {request.UserId} and ProjectId {request.ProjectId}");

            assignment.Role = (Domain.ValueObjects.UserRole)request.Role;

            await dbContext.SaveChangesAsync();

            return(new ChangeUserRoleResponse {
            });
        }
Exemplo n.º 2
0
 public async Task <ChangeUserRoleResponse> ChangeUserRole([FromBody] ChangeUserRoleRequest request) => await _mediator.Send(request);