public async Task EditProject(EditProjectDto dto) { var project = await _projectsDbSet .Include(p => p.Members) .Include(p => p.Wall.Members) .Include(p => p.Wall.Moderators) .Include(p => p.Attributes) .FirstOrDefaultAsync(p => p.Id == dto.Id && p.OrganizationId == dto.OrganizationId); if (project == null) { throw new ValidationException(ErrorCodes.ContentDoesNotExist, "Project not found"); } ValidateOwnershipPermissions(project.OwnerId, dto); if (project.OwnerId != dto.OwningUserId) { var owningUserExists = await _usersDbSet.AnyAsync(u => u.Id == dto.OwningUserId && u.OrganizationId == dto.OrganizationId); if (!owningUserExists) { throw new ValidationException(ErrorCodes.ContentDoesNotExist, "User not found"); } } project.Members = await _usersDbSet.Where(x => dto.MembersIds.Contains(x.Id)).ToListAsync(); _wallService.ReplaceMembersInWall(project.Members.ToList(), project.WallId, dto.UserId); var completeListOfAttributes = await ManageProjectAttributes(dto.Attributes); project.Name = dto.Title; project.Desc = dto.Description; project.Logo = dto.Logo; project.OwnerId = dto.OwningUserId; project.Attributes = completeListOfAttributes.ToList(); UpdateProjectWallModerator(dto, project); UpdateWall(dto, project.WallId); await _uow.SaveChangesAsync(dto.UserId); }