Skip to content

Commit

Permalink
(#412) events: remove student id from the evnet document
Browse files Browse the repository at this point in the history
  • Loading branch information
SaintAngeLs committed Sep 16, 2024
1 parent a97ce1e commit 7a7f21b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ public static EventDto AsDto(this EventDocument document, Guid studentId)
UpdatedAt = document.UpdatedAt,
Visibility = document.Visibility,
Settings = document.Settings.AsDto(),
IsSignedUp = document.SignedUpStudents.Any(x => x.StudentId == studentId),
IsInterested = document.InterestedStudents.Any(x => x.StudentId == studentId),
StudentRating = document.Ratings.FirstOrDefault(x => x.StudentId == studentId)?.Value,
IsSignedUp = document.SignedUpStudents.Any(x => x.UserId == studentId),
IsInterested = document.InterestedStudents.Any(x => x.UserId == studentId),
StudentRating = document.Ratings.FirstOrDefault(x => x.UserId == studentId)?.Value,
FriendsInterestedIn = Enumerable.Empty<ParticipantDto>(),
FriendsSignedUp = Enumerable.Empty<ParticipantDto>()
};
Expand Down Expand Up @@ -62,9 +62,9 @@ public static EventDto AsDto(this Event @event, Guid studentId)
UpdatedAt = @event.UpdatedAt,
Visibility = @event.Visibility,
Settings = new EventSettingsDto(@event.Settings),
IsSignedUp = @event.SignedUpParticipants.Any(x => x.StudentId == studentId),
IsInterested = @event.InterestedParticipants.Any(x => x.StudentId == studentId),
StudentRating = @event.Ratings.FirstOrDefault(x => x.StudentId == studentId)?.Value,
IsSignedUp = @event.SignedUpParticipants.Any(x => x.UserId == studentId),
IsInterested = @event.InterestedParticipants.Any(x => x.UserId == studentId),
StudentRating = @event.Ratings.FirstOrDefault(x => x.UserId == studentId)?.Value,
FriendsInterestedIn = Enumerable.Empty<ParticipantDto>(),
FriendsSignedUp = Enumerable.Empty<ParticipantDto>()
};
Expand Down Expand Up @@ -103,10 +103,10 @@ public static EventDto AsDtoWithFriends(this EventDocument document, Guid studen
{
var eventDto = document.AsDto(studentId);
eventDto.FriendsInterestedIn = document.InterestedStudents
.Where(x => friends.Any(f => f.FriendId == x.StudentId))
.Where(x => friends.Any(f => f.FriendId == x.UserId))
.Select(p => p.AsDto());
eventDto.FriendsSignedUp = document.SignedUpStudents
.Where(x => friends.Any(f => f.FriendId == x.StudentId))
.Where(x => friends.Any(f => f.FriendId == x.UserId))
.Select(p => p.AsDto());
return eventDto;
}
Expand Down Expand Up @@ -148,22 +148,22 @@ public static ParticipantDto AsDto(this ParticipantDocument document)
{
return new ParticipantDto
{
StudentId = document.StudentId
UserId = document.UserId
};
}

public static ParticipantDocument AsDocument(this Participant entity)
{
return new ParticipantDocument
{
StudentId = entity.StudentId
UserId = entity.UserId
};
}

public static ParticipantDto ToDto(this ParticipantDocument document)
=> new ParticipantDto
{
StudentId = document.StudentId,
UserId = document.UserId,
};


Expand Down Expand Up @@ -229,17 +229,17 @@ public static EventSettings AsEntity(this EventSettingsDocument document)
};

public static Participant AsEntity(this ParticipantDocument document)
=> new (document.StudentId);
=> new (document.UserId);

public static RatingDto AsRatingDto(this RatingDocument document)
=> new ()
{
StudentId = document.StudentId,
StudentId = document.UserId,
Value = document.Value
};

public static Rating AsEntity(this RatingDocument document)
=> new (document.StudentId, document.Value);
=> new (document.UserId, document.Value);


public static CommentDocument AsDocument(this Comment comment)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ namespace MiniSpace.Services.Events.Infrastructure.Mongo.Documents
[ExcludeFromCodeCoverage]
public class ParticipantDocument
{
public Guid StudentId { get; set; }
public Guid UserId { get; set; }

public static ParticipantDocument FromEntity(Participant participant)
{
return new ParticipantDocument
{
StudentId = participant.StudentId,
UserId = participant.UserId,
};
}

public Participant ToEntity()
{
return new Participant(StudentId);
return new Participant(UserId);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ namespace MiniSpace.Services.Events.Infrastructure.Mongo.Documents
[ExcludeFromCodeCoverage]
public class RatingDocument
{
public Guid StudentId { get; set; }
public Guid UserId { get; set; }
public int Value { get; set; }

public static RatingDocument FromEntity(Rating rating)
{
return new RatingDocument
{
StudentId = rating.StudentId,
UserId = rating.UserId,
Value = rating.Value
};
}

public Rating ToEntity()
{
return new Rating(StudentId, Value);
return new Rating(UserId, Value);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,13 @@ public static FilterDefinition<EventDocument> AddFriendsFilter (this FilterDefin
if (friendsEngagementType != null)
{
filterDefinition &= friendsEngagementType == EventEngagementType.InterestedIn
? FilterDefinitionBuilder.ElemMatch(x => x.InterestedStudents, s => friends.Contains(s.StudentId))
: FilterDefinitionBuilder.ElemMatch(x => x.SignedUpStudents, s => friends.Contains(s.StudentId));
? FilterDefinitionBuilder.ElemMatch(x => x.InterestedStudents, s => friends.Contains(s.UserId))
: FilterDefinitionBuilder.ElemMatch(x => x.SignedUpStudents, s => friends.Contains(s.UserId));
}
else
{
var interestedFilter = FilterDefinitionBuilder.ElemMatch(x => x.InterestedStudents, s => friends.Contains(s.StudentId));
var signedUpFilter = FilterDefinitionBuilder.ElemMatch(x => x.SignedUpStudents, s => friends.Contains(s.StudentId));
var interestedFilter = FilterDefinitionBuilder.ElemMatch(x => x.InterestedStudents, s => friends.Contains(s.UserId));
var signedUpFilter = FilterDefinitionBuilder.ElemMatch(x => x.SignedUpStudents, s => friends.Contains(s.UserId));
filterDefinition &= FilterDefinitionBuilder.Or(interestedFilter, signedUpFilter);
}

Expand Down

0 comments on commit 7a7f21b

Please sign in to comment.