43 lines
1.4 KiB
C#
43 lines
1.4 KiB
C#
using GmRelay.Shared.Domain;
|
|
|
|
namespace GmRelay.Shared.Features.Confirmation.HandleRsvp;
|
|
|
|
public sealed record RsvpFlowDecision(
|
|
string CallbackText,
|
|
bool ShouldAlertGm,
|
|
bool ShouldRevertSessionToConfirmationSent,
|
|
bool ShouldMarkSessionConfirmed,
|
|
bool ShouldNotifyGroup,
|
|
bool ShouldNotifyGm);
|
|
|
|
public static class RsvpFlowRules
|
|
{
|
|
public static RsvpFlowDecision Evaluate(
|
|
string requestedStatus,
|
|
string currentSessionStatus,
|
|
int totalParticipants,
|
|
int confirmedParticipants)
|
|
{
|
|
if (requestedStatus == RsvpStatus.Declined)
|
|
{
|
|
return new RsvpFlowDecision(
|
|
CallbackText: "Вы отказались от участия.",
|
|
ShouldAlertGm: true,
|
|
ShouldRevertSessionToConfirmationSent: currentSessionStatus == SessionStatus.Confirmed,
|
|
ShouldMarkSessionConfirmed: false,
|
|
ShouldNotifyGroup: false,
|
|
ShouldNotifyGm: false);
|
|
}
|
|
|
|
var everyoneConfirmed = confirmedParticipants == totalParticipants;
|
|
|
|
return new RsvpFlowDecision(
|
|
CallbackText: "Вы подтвердили участие!",
|
|
ShouldAlertGm: false,
|
|
ShouldRevertSessionToConfirmationSent: false,
|
|
ShouldMarkSessionConfirmed: everyoneConfirmed,
|
|
ShouldNotifyGroup: everyoneConfirmed,
|
|
ShouldNotifyGm: everyoneConfirmed);
|
|
}
|
|
}
|