public async Task OnGetAsync() { string NameOnly; int VolumeNumber; var regex = new Regex(@"([A-Z]+)\.?(\d*)"); var match = regex.Match(ConfName); if (match.Success && match.Groups.Count > 2) { NameOnly = match.Groups[1].Value; if (int.TryParse(match.Groups[2].Value, out int volNo)) { VolumeNumber = volNo; } else { VolumeNumber = 0; } } else { NameOnly = ConfName; VolumeNumber = 0; } Conference = await _context.Conferences .Include(c => c.ConfTopics) .Where(c => c.Name == NameOnly && c.VolumeNo == VolumeNumber && !c.Status.HasFlag(ConfStatus.Private)) .OrderBy(c => c.Name) .ThenBy(c => c.VolumeNo) .FirstOrDefaultAsync(); Topic = Conference.ConfTopics .Where(t => t.Name.Equals(TopicName, StringComparison.InvariantCultureIgnoreCase)) .FirstOrDefault(); // Topic Selection if (Topic != null) { Messages = await _context.ConfMessages .Include(m => m.MessageText) .Where(m => m.TopicId == Topic.Id && ((m.Status & ConfMessage.MessageStatus.Deleted) == 0)) .OrderBy(m => m.TopicId) .ThenBy(m => m.MsgNo) .ToListAsync(); } _logger.LogInformation($"Got conference {Conference} ConfName={ConfName}, TopicName={TopicName}, Messages: {Messages?.Count()}"); }
public static string FormatTopic(ConfTopic topic) { var sb = new StringBuilder(); var typ = topic.Status.GetType(); var values = Enum.GetValues(typ).Cast <ConfTopic.TopicStatus>() .Where(v => topic.Status.HasFlag(v)); var valStrs = new List <string>(); foreach (var value in values) { valStrs.Add(Enum.GetName(typ, value)); } sb.AppendFormat("{0,2}. {1,-16} {2,5}", topic.TopicNo, topic.Name, topic.NextSequence); if (topic.RedirectTo != null) { sb.Append(string.Format(" -> {0}", topic.RedirectTo.Name)); } sb.Append(' '); sb.Append(string.Join(", ", valStrs)); return(sb.ToString()); }