forked from Sarah/Lieb-Website
Added minUsers and Polls
This commit is contained in:
parent
cb1dbfbf98
commit
1d999e89bf
8 changed files with 45 additions and 10 deletions
|
@ -97,7 +97,7 @@ namespace Lieb.Data
|
|||
await context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task UpdateAnswer(int pollId, int pollOptionId, ulong userId)
|
||||
public async Task UpdateAnswer(int pollId, int pollOptionId, string answer, ulong userId)
|
||||
{
|
||||
using var context = _contextFactory.CreateDbContext();
|
||||
Poll? poll = context.Polls
|
||||
|
@ -106,8 +106,10 @@ namespace Lieb.Data
|
|||
|
||||
if (poll == null) return;
|
||||
|
||||
PollAnswer answer = poll.Answers.First(a => a.UserId == userId);
|
||||
answer.PollOptionId = pollOptionId;
|
||||
PollAnswer pollAnswer = poll.Answers.First(a => a.UserId == userId);
|
||||
pollAnswer.Answer = answer;
|
||||
pollAnswer.PollOptionId = pollOptionId;
|
||||
await context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task AddUser(int pollId, ulong userId)
|
||||
|
|
|
@ -469,7 +469,7 @@ namespace Lieb.Data
|
|||
}
|
||||
|
||||
if (raid.SignUps.Count < raid.MinUsers
|
||||
&& raid.MinUserDeadLineUTC.UtcDateTime > DateTimeOffset.UtcNow)
|
||||
&& raid.MinUserDeadLineUTC < DateTimeOffset.UtcNow)
|
||||
{
|
||||
errorMessage = $"The raid was canceled because of not enough sign ups.";
|
||||
return false;
|
||||
|
@ -722,10 +722,9 @@ namespace Lieb.Data
|
|||
Poll poll = _pollService.GetPoll(raid.MinUserPollId.Value);
|
||||
|
||||
if (poll.Answers.Count == 0) continue;
|
||||
if (poll.Answers.Where(a => a.PollOptionId == null).Any()) continue;
|
||||
if (poll.Answers.Where(a => string.IsNullOrEmpty(a.Answer)).Any()) continue;
|
||||
|
||||
int noOptionId = poll.Options.First(o => o.Name == Constants.Polls.NO).PollOptionId;
|
||||
if(poll.Answers.Where(a => a.PollOptionId == noOptionId).Any())
|
||||
if(poll.Answers.Where(a => a.Answer == Constants.Polls.NO).Any())
|
||||
{
|
||||
await _discordService.SendMessageToRaidUsers("The raid is canceled.", raid);
|
||||
}
|
||||
|
|
|
@ -13,14 +13,16 @@ namespace Lieb.Data
|
|||
|
||||
public async ValueTask<DateTimeOffset> GetLocalDateTime(DateTimeOffset dateTime)
|
||||
{
|
||||
int offsetInMinutes = await _jsRuntime.InvokeAsync<int>("GetTimezoneValue", dateTime);
|
||||
TimeSpan userOffset = TimeSpan.FromMinutes(-offsetInMinutes);
|
||||
if(dateTime == DateTimeOffset.MinValue) dateTime = DateTimeOffset.UtcNow;
|
||||
int offsetInMinutes = await _jsRuntime.InvokeAsync<int>("GetTimezoneValue", dateTime);
|
||||
TimeSpan userOffset = TimeSpan.FromMinutes(-offsetInMinutes);
|
||||
|
||||
return dateTime.ToOffset(userOffset);
|
||||
}
|
||||
|
||||
public async ValueTask<DateTimeOffset> GetUTCDateTime(DateTimeOffset dateTime)
|
||||
{
|
||||
if(dateTime == DateTimeOffset.MinValue) return DateTimeOffset.UtcNow;
|
||||
int offsetInMinutes = await _jsRuntime.InvokeAsync<int>("GetTimezoneValue", dateTime);
|
||||
TimeSpan userOffset = TimeSpan.FromMinutes(-offsetInMinutes);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue