namespace GmRelay.Bot.Features.Sessions.RescheduleSession; internal enum RescheduleVoteOutcome { Pending, Rejected, Approved } internal sealed record RescheduleVoteDecision( RescheduleVoteOutcome Outcome, string CallbackText, bool ShouldRescheduleSession, bool ShouldResetParticipantRsvps); internal static class RescheduleVoteRules { public static RescheduleVoteDecision Evaluate(string vote, int totalParticipants, int approvedParticipants) { if (string.Equals(vote, "no", StringComparison.OrdinalIgnoreCase)) { return new RescheduleVoteDecision( Outcome: RescheduleVoteOutcome.Rejected, CallbackText: "\u0412\u044b \u043f\u0440\u043e\u0433\u043e\u043b\u043e\u0441\u043e\u0432\u0430\u043b\u0438 \u043f\u0440\u043e\u0442\u0438\u0432 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0430.", ShouldRescheduleSession: false, ShouldResetParticipantRsvps: false); } var everyoneApproved = approvedParticipants == totalParticipants; return new RescheduleVoteDecision( Outcome: everyoneApproved ? RescheduleVoteOutcome.Approved : RescheduleVoteOutcome.Pending, CallbackText: everyoneApproved ? "\u0412\u044b \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0434\u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u043d\u043e\u0441! \u0412\u0441\u0435 \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u044b \u2014 \u0432\u0440\u0435\u043c\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u043e." : "\u0412\u044b \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0434\u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u043d\u043e\u0441!", ShouldRescheduleSession: everyoneApproved, ShouldResetParticipantRsvps: everyoneApproved); } }