33 lines
970 B
C#
33 lines
970 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace Tornado3_2026Election.Domain;
|
|
|
|
public sealed class ElectionDataSnapshot
|
|
{
|
|
public required BroadcastPhase BroadcastPhase { get; init; }
|
|
|
|
public required string ElectionType { get; init; }
|
|
|
|
public required string DistrictName { get; init; }
|
|
|
|
public required string DistrictCode { get; init; }
|
|
|
|
public required IReadOnlyList<CandidateEntry> Candidates { get; init; }
|
|
|
|
public required int TotalExpectedVotes { get; init; }
|
|
|
|
public required int TurnoutVotes { get; init; }
|
|
|
|
public required DateTimeOffset ReceivedAt { get; init; }
|
|
|
|
public int CountedVotes => Candidates.Sum(candidate => candidate.VoteCount);
|
|
|
|
public int RemainingVotes => Math.Max(0, TotalExpectedVotes - CountedVotes);
|
|
|
|
public double TurnoutRate => TotalExpectedVotes <= 0
|
|
? 0
|
|
: Math.Round(TurnoutVotes * 100d / TotalExpectedVotes, 1, MidpointRounding.AwayFromZero);
|
|
}
|