forked from Sarah/Lieb-Website
reformated PollOptions
used HashSet for PollUsers
This commit is contained in:
parent
1f5a1f4fe2
commit
7e87500992
3 changed files with 36 additions and 19 deletions
|
@ -73,11 +73,11 @@ namespace Lieb.Data
|
|||
.FirstOrDefault(r => r.RaidId == raidId);
|
||||
|
||||
if (raid == null) return 0;
|
||||
List<ulong> users = raid.SignUps.Where(s => s.LiebUserId != null).Select(s => (ulong)s.LiebUserId).ToList();
|
||||
HashSet<ulong> users = raid.SignUps.Where(s => s.LiebUserId != null).Select(s => (ulong)s.LiebUserId).ToHashSet();
|
||||
return await CreatePoll(poll, users, raidId);
|
||||
}
|
||||
|
||||
public async Task<int> CreatePoll(Poll poll, List<ulong> users, int? raidId = null)
|
||||
public async Task<int> CreatePoll(Poll poll, HashSet<ulong> users, int? raidId = null)
|
||||
{
|
||||
poll.RaidId = raidId;
|
||||
|
||||
|
|
|
@ -193,7 +193,7 @@
|
|||
}
|
||||
else if(_pollType == POLL_TYPE_GROUP)
|
||||
{
|
||||
await PollService.CreatePoll(_poll, UserService.GetGroupMembers(_chosenRole).Select(u => u.Id).ToList());
|
||||
await PollService.CreatePoll(_poll, UserService.GetGroupMembers(_chosenRole).Select(u => u.Id).ToHashSet());
|
||||
}
|
||||
|
||||
NavigationManager.NavigateTo("polloverview");
|
||||
|
|
|
@ -10,23 +10,24 @@
|
|||
@inject NavigationManager NavigationManager
|
||||
|
||||
<body>
|
||||
<div @onclick="() => _isCollapsed = !_isCollapsed">
|
||||
|
||||
<div @onclick="() => _isCollapsed = !_isCollapsed">
|
||||
|
||||
<h5>@_poll.Question</h5>
|
||||
@if(_raid != null)
|
||||
{
|
||||
<p>@_raid.Title - @_raid.StartTimeUTC.DateTime.ToLongDateString()</p>
|
||||
}
|
||||
</div>
|
||||
|
||||
@if (!_isCollapsed)
|
||||
{
|
||||
@foreach(var answer in _poll.Answers.GroupBy(a => a.Answer))
|
||||
<h5>@_poll.Question</h5>
|
||||
@if(_raid != null)
|
||||
{
|
||||
<p>@answer.Key - @answer.Count() </p>
|
||||
<p>@_raid.Title - @_raid.StartTimeUTC.DateTime.ToLongDateString()</p>
|
||||
}
|
||||
}
|
||||
|
||||
@if (!_isCollapsed)
|
||||
{
|
||||
@foreach(var answer in Answers)
|
||||
{
|
||||
<p>@answer.Key - @answer.Value </p>
|
||||
}
|
||||
}
|
||||
<br/>
|
||||
<p>Not Answered - @_poll.Answers.Where(a => string.IsNullOrWhiteSpace(a.Answer)).Count() </p>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
@code {
|
||||
|
@ -36,9 +37,11 @@
|
|||
[Parameter]
|
||||
public LiebUser? _user { get; set; }
|
||||
|
||||
public Raid _raid { get; set; }
|
||||
private Raid _raid { get; set; }
|
||||
|
||||
bool _isCollapsed = true;
|
||||
private bool _isCollapsed = true;
|
||||
|
||||
private Dictionary<string, int> Answers = new Dictionary<string, int>();
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
|
@ -46,6 +49,20 @@
|
|||
{
|
||||
_raid = RaidService.GetRaid(_poll.RaidId.Value);
|
||||
}
|
||||
foreach(PollOption option in _poll.Options)
|
||||
{
|
||||
if(!Answers.ContainsKey(option.Name))
|
||||
Answers.Add(option.Name, 0);
|
||||
}
|
||||
foreach(PollAnswer answer in _poll.Answers)
|
||||
{
|
||||
if(!string.IsNullOrWhiteSpace(answer.Answer))
|
||||
{
|
||||
if(!Answers.ContainsKey(answer.Answer))
|
||||
Answers.Add(answer.Answer, 0);
|
||||
Answers[answer.Answer] ++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue