Example #1
0
        public override async Task <RemoveUserFromProjectResponse> RemoveUserFromProject(RemoveUserFromProjectRequest 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>($"projectId {request.ProjectId} userId {request.UserId}");

            dbContext.UserProjectAssignments.Remove(assignment);

            await dbContext.SaveChangesAsync();

            return(new RemoveUserFromProjectResponse {
            });
        }
Example #2
0
        public override async Task <RemoveUserFromProjectResponse> RemoveUserFromProject(RemoveUserFromProjectRequest request, ServerCallContext context)
        {
            var domain = await dbContext.Projects.FindIfNullThrowAsync(request.ProjectId);

            var user = await dbContext.Users.FindIfNullThrowAsync(request.UserId);

            var assignment = await dbContext.UserProjectAssignments.FirstIfNotNullThrowAsync(x => x.Project == domain && x.User == user);

            dbContext.UserProjectAssignments.Remove(assignment);

            await dbContext.SaveChangesAsync();

            return(new RemoveUserFromProjectResponse {
            });
        }