Skip to content

Commit 7a7655c

Browse files
committed
(#411) events: refactor events core
1 parent 0d00f4b commit 7a7655c

10 files changed

+41
-41
lines changed

MiniSpace.Services.Events/src/MiniSpace.Services.Events.Core/Entities/Event.cs

+9-9
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,9 @@ public void SignUpParticipant(Participant participant)
116116

117117
public void AddParticipant(Participant participant)
118118
{
119-
if (SignedUpParticipants.Any(p => p.StudentId == participant.StudentId))
119+
if (SignedUpParticipants.Any(p => p.UserId == participant.UserId))
120120
{
121-
throw new StudentAlreadySignedUpException(participant.StudentId, Id);
121+
throw new StudentAlreadySignedUpException(participant.UserId, Id);
122122
}
123123

124124
if (SignedUpParticipants.Count() >= Capacity)
@@ -147,7 +147,7 @@ public void CancelSignUp(Guid studentId)
147147

148148
public void RemoveParticipant(Guid studentId)
149149
{
150-
var participant = _signedUpParticipants.SingleOrDefault(p => p.StudentId == studentId);
150+
var participant = _signedUpParticipants.SingleOrDefault(p => p.UserId == studentId);
151151
if (participant is null)
152152
{
153153
throw new StudentNotSignedUpException(studentId, Id);
@@ -180,17 +180,17 @@ public void AddGalleryImage(string newImageUrl)
180180

181181
public void ShowParticipantInterest(Participant participant)
182182
{
183-
if (InterestedParticipants.Any(p => p.StudentId == participant.StudentId))
183+
if (InterestedParticipants.Any(p => p.UserId == participant.UserId))
184184
{
185-
throw new StudentAlreadyInterestedInEventException(participant.StudentId, Id);
185+
throw new StudentAlreadyInterestedInEventException(participant.UserId, Id);
186186
}
187187

188188
_interestedParticipants.Add(participant);
189189
}
190190

191191
public void CancelInterest(Guid studentId)
192192
{
193-
var participant = _interestedParticipants.SingleOrDefault(p => p.StudentId == studentId);
193+
var participant = _interestedParticipants.SingleOrDefault(p => p.UserId == studentId);
194194
if (participant is null)
195195
{
196196
throw new StudentNotInterestedInEventException(studentId, Id);
@@ -206,7 +206,7 @@ public void Rate(Guid studentId, int rating)
206206
throw new InvalidEventState(Id, State.Archived, State);
207207
}
208208

209-
if (_signedUpParticipants.All(p => p.StudentId != studentId))
209+
if (_signedUpParticipants.All(p => p.UserId != studentId))
210210
{
211211
throw new StudentNotSignedUpForEventException(Id, studentId);
212212
}
@@ -216,7 +216,7 @@ public void Rate(Guid studentId, int rating)
216216
throw new InvalidRatingValueException(rating);
217217
}
218218

219-
if (_ratings.Any(r => r.StudentId == studentId))
219+
if (_ratings.Any(r => r.UserId == studentId))
220220
{
221221
throw new StudentAlreadyRatedException(studentId, Id);
222222
}
@@ -226,7 +226,7 @@ public void Rate(Guid studentId, int rating)
226226

227227
public void CancelRate(Guid studentId)
228228
{
229-
var rating = _ratings.SingleOrDefault(r => r.StudentId == studentId);
229+
var rating = _ratings.SingleOrDefault(r => r.UserId == studentId);
230230
if (rating is null)
231231
{
232232
throw new StudentNotRatedEventException(studentId, Id);

MiniSpace.Services.Events/src/MiniSpace.Services.Events.Core/Entities/Participant.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace MiniSpace.Services.Events.Core.Entities
44
{
5-
public class Participant(Guid studentId)
5+
public class Participant(Guid userId)
66
{
7-
public Guid StudentId { get; set; } = studentId;
7+
public Guid UserId { get; set; } = userId;
88
}
99
}

MiniSpace.Services.Events/src/MiniSpace.Services.Events.Core/Entities/Rating.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
namespace MiniSpace.Services.Events.Core.Entities
44
{
5-
public class Rating(Guid studentId, int value)
5+
public class Rating(Guid userId, int value)
66
{
7-
public Guid StudentId { get; set; } = studentId;
7+
public Guid UserId { get; set; } = userId;
88
public int Value { get; set; } = value;
99
}
1010
}

MiniSpace.Services.Events/src/MiniSpace.Services.Events.Core/Exceptions/StudentAlreadyInterestedInEventException.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ public class StudentAlreadyInterestedInEventException : DomainException
66
{
77
public override string Code { get; } = "student_already_interested_in_event";
88
public Guid EventId { get; }
9-
public Guid StudentId { get; }
9+
public Guid UserId { get; }
1010

11-
public StudentAlreadyInterestedInEventException(Guid studentId, Guid eventId)
12-
: base($"Student with ID: {studentId} is already interested in event with ID: {eventId}.")
11+
public StudentAlreadyInterestedInEventException(Guid userId, Guid eventId)
12+
: base($"Student with ID: {userId} is already interested in event with ID: {eventId}.")
1313
{
14-
StudentId = studentId;
14+
UserId = userId;
1515
EventId = eventId;
1616
}
1717
}

MiniSpace.Services.Events/src/MiniSpace.Services.Events.Core/Exceptions/StudentAlreadyRatedException.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ namespace MiniSpace.Services.Events.Core.Exceptions
55
public class StudentAlreadyRatedException : DomainException
66
{
77
public override string Code { get; } = "student_already_rated";
8-
public Guid StudentId { get; }
8+
public Guid UserId { get; }
99
public Guid EventId { get; }
1010

11-
public StudentAlreadyRatedException(Guid studentId, Guid eventId) : base(
12-
$"Student with ID: {studentId} has already rated event with ID: {eventId}.")
11+
public StudentAlreadyRatedException(Guid userId, Guid eventId) : base(
12+
$"Student with ID: {userId} has already rated event with ID: {eventId}.")
1313
{
14-
StudentId = studentId;
14+
UserId = userId;
1515
EventId = eventId;
1616
}
1717
}

MiniSpace.Services.Events/src/MiniSpace.Services.Events.Core/Exceptions/StudentAlreadySignedUpException.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ namespace MiniSpace.Services.Events.Core.Exceptions
55
public class StudentAlreadySignedUpException : DomainException
66
{
77
public override string Code { get; } = "student_already_signed_up";
8-
public Guid StudentId { get; }
8+
public Guid UserId { get; }
99
public Guid EventId { get; }
1010

11-
public StudentAlreadySignedUpException(Guid studentId, Guid eventId) : base(
12-
$"Student with ID: {studentId} already signed up to event with ID: {eventId}.")
11+
public StudentAlreadySignedUpException(Guid userId, Guid eventId) : base(
12+
$"Student with ID: {userId} already signed up to event with ID: {eventId}.")
1313
{
14-
StudentId = studentId;
14+
UserId = userId;
1515
EventId = eventId;
1616
}
1717
}

MiniSpace.Services.Events/src/MiniSpace.Services.Events.Core/Exceptions/StudentNotInterestedInEventException.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ namespace MiniSpace.Services.Events.Core.Exceptions
55
public class StudentNotInterestedInEventException : DomainException
66
{
77
public override string Code { get; } = "student_is_not_interested_in_event";
8-
public Guid StudentId { get; }
8+
public Guid UserId { get; }
99
public Guid EventId { get; }
1010

11-
public StudentNotInterestedInEventException(Guid studentId, Guid eventId)
12-
: base($"Student with ID: '{studentId}' is not interested in event with ID: '{eventId}'.")
11+
public StudentNotInterestedInEventException(Guid userId, Guid eventId)
12+
: base($"Student with ID: '{userId}' is not interested in event with ID: '{eventId}'.")
1313
{
14-
StudentId = studentId;
14+
UserId = userId;
1515
EventId = eventId;
1616
}
1717
}

MiniSpace.Services.Events/src/MiniSpace.Services.Events.Core/Exceptions/StudentNotRatedEventException.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ public class StudentNotRatedEventException : DomainException
66
{
77
public override string Code { get; } = "student_not_rated_event";
88
public Guid EventId { get; }
9-
public Guid StudentId { get; }
9+
public Guid UserId { get; }
1010

11-
public StudentNotRatedEventException(Guid eventId, Guid studentId)
12-
: base($"Student with ID: '{studentId}' has not rated event with ID: '{eventId}'.")
11+
public StudentNotRatedEventException(Guid eventId, Guid userId)
12+
: base($"Student with ID: '{userId}' has not rated event with ID: '{eventId}'.")
1313
{
1414
EventId = eventId;
15-
StudentId = studentId;
15+
UserId = userId;
1616
}
1717
}
1818
}

MiniSpace.Services.Events/src/MiniSpace.Services.Events.Core/Exceptions/StudentNotSignedUpException.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ namespace MiniSpace.Services.Events.Core.Exceptions
55
public class StudentNotSignedUpException : DomainException
66
{
77
public override string Code { get; } = "student_not_signed_up";
8-
public Guid StudentId { get; }
8+
public Guid UserId { get; }
99
public Guid EventId { get; }
1010

11-
public StudentNotSignedUpException(Guid studentId, Guid eventId)
12-
: base($"Student with ID: '{studentId}' has not signed up to event with ID: '{eventId}'.")
11+
public StudentNotSignedUpException(Guid userId, Guid eventId)
12+
: base($"Student with ID: '{userId}' has not signed up to event with ID: '{eventId}'.")
1313
{
14-
StudentId = studentId;
14+
UserId = userId;
1515
EventId = eventId;
1616
}
1717
}

MiniSpace.Services.Events/src/MiniSpace.Services.Events.Core/Exceptions/StudentNotSignedUpForEventException.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ public class StudentNotSignedUpForEventException : DomainException
66
{
77
public override string Code { get; } = "student_not_signed_for_event";
88
public Guid EventId { get; }
9-
public Guid StudentId { get; }
9+
public Guid UserId { get; }
1010

11-
public StudentNotSignedUpForEventException(Guid eventId, Guid studentId)
12-
: base($"Student with ID: '{studentId}' is not signed for event with ID: '{eventId}'.")
11+
public StudentNotSignedUpForEventException(Guid eventId, Guid userId)
12+
: base($"Student with ID: '{userId}' is not signed for event with ID: '{eventId}'.")
1313
{
1414
EventId = eventId;
15-
StudentId = studentId;
15+
UserId = userId;
1616
}
1717
}
1818
}

0 commit comments

Comments
 (0)