private void CalculateParticipationBlock(RaidParticipation raid, StringBuilder sb, out string tps) { var userSettingsCollection = DB.GetCollection <UserSettings>(); List <string> tpsElements = new List <string>(); tps = String.Empty; int counter = 0; foreach (Team team in raid.Participants.Keys.OrderBy(x => x)) { var participants = raid.Participants[team]; if (participants.Count > 0) { sb.AppendLine(); sb.AppendLine($"<b>{team.AsReadableString()} ({participants.Select(x => 1 + x.Extra).Sum()}):</b>"); foreach (UserParticipation userParticipation in participants.OrderBy(p => p.User.ShortName())) { string name = userParticipation.User.ShortName().TrimStart('@'); UserSettings userRecord = userSettingsCollection.Find(x => x.User.ID == userParticipation.User.ID).FirstOrDefault(); if (!String.IsNullOrWhiteSpace(userRecord?.Alias)) { name = userRecord.Alias; } if (userRecord?.Level > 0) { name += $" (" + this._HTML_(I18N.GetString("level")) + $" {userRecord?.Level})"; } sb.Append($" - {MessageUtils.HtmlEscape(name)}"); if (userParticipation.Extra > 0) { counter += userParticipation.Extra; sb.Append($" +{userParticipation.Extra}"); } if (userParticipation.UtcArrived != default) { // Text and plural text are the same in this case. string arrivedAtString = this._HTML_(I18N.GetPluralString("there for {0}", "there for {0}", userParticipation.Extra + 1, TimeService.AsReadableTimespan(DateTime.UtcNow - userParticipation.UtcArrived))); sb.Append($" [{arrivedAtString}]"); } else if (userParticipation.UtcWhen != default) { sb.Append($" [{TimeService.AsShortTime(userParticipation.UtcWhen)}]"); } if (userParticipation.Type != default) { sb.Append($" {this.GetParticipationTypeTitle(userParticipation.Type)}"); } sb.AppendLine(); } } tpsElements.Add($"{participants.Sum(x => 1 + x.Extra)}{team.AsIcon()}"); counter += participants.Count; } var tpsSub = string.Join(" ", tpsElements); tps = $"{counter} ({tpsSub})"; }