added error message if signing up fails
This commit is contained in:
parent
766faf7b66
commit
2246624917
6 changed files with 79 additions and 40 deletions
|
@ -87,67 +87,67 @@ namespace Lieb.Controllers
|
|||
|
||||
[HttpPost]
|
||||
[Route("[action]")]
|
||||
public async Task SignUp(ApiSignUp signUp)
|
||||
public async Task<bool> SignUp(ApiSignUp signUp)
|
||||
{
|
||||
if(signUp.userId != 0)
|
||||
{
|
||||
int accountId = _userService.GetSignUpAccount(signUp.userId, signUp.raidId, signUp.gw2AccountId);
|
||||
await _raidService.SignUp(signUp.raidId, signUp.userId, accountId, signUp.roleId, SignUpType.SignedUp, signUp.signedUpByUserId);
|
||||
return await _raidService.SignUp(signUp.raidId, signUp.userId, accountId, signUp.roleId, SignUpType.SignedUp, signUp.signedUpByUserId);
|
||||
}
|
||||
else
|
||||
{
|
||||
await _raidService.SignUpExternalUser(signUp.raidId, signUp.userName, signUp.roleId, SignUpType.SignedUp, signUp.signedUpByUserId);
|
||||
return await _raidService.SignUpExternalUser(signUp.raidId, signUp.userName, signUp.roleId, SignUpType.SignedUp, signUp.signedUpByUserId);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Route("[action]")]
|
||||
public async Task SignUpMaybe(ApiSignUp signUp)
|
||||
public async Task<bool> SignUpMaybe(ApiSignUp signUp)
|
||||
{
|
||||
if(signUp.userId != 0)
|
||||
{
|
||||
int accountId = _userService.GetSignUpAccount(signUp.userId, signUp.raidId, signUp.gw2AccountId);
|
||||
await _raidService.SignUp(signUp.raidId, signUp.userId, accountId, signUp.roleId, SignUpType.Maybe, signUp.signedUpByUserId);
|
||||
return await _raidService.SignUp(signUp.raidId, signUp.userId, accountId, signUp.roleId, SignUpType.Maybe, signUp.signedUpByUserId);
|
||||
}
|
||||
else
|
||||
{
|
||||
await _raidService.SignUpExternalUser(signUp.raidId, signUp.userName, signUp.roleId, SignUpType.Maybe, signUp.signedUpByUserId);
|
||||
return await _raidService.SignUpExternalUser(signUp.raidId, signUp.userName, signUp.roleId, SignUpType.Maybe, signUp.signedUpByUserId);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Route("[action]")]
|
||||
public async Task SignUpBackup(ApiSignUp signUp)
|
||||
public async Task<bool> SignUpBackup(ApiSignUp signUp)
|
||||
{
|
||||
if(signUp.userId != 0)
|
||||
{
|
||||
int accountId = _userService.GetSignUpAccount(signUp.userId, signUp.raidId, signUp.gw2AccountId);
|
||||
await _raidService.SignUp(signUp.raidId, signUp.userId, accountId, signUp.roleId, SignUpType.Backup, signUp.signedUpByUserId);
|
||||
return await _raidService.SignUp(signUp.raidId, signUp.userId, accountId, signUp.roleId, SignUpType.Backup, signUp.signedUpByUserId);
|
||||
}
|
||||
else
|
||||
{
|
||||
await _raidService.SignUpExternalUser(signUp.raidId, signUp.userName, signUp.roleId, SignUpType.Backup, signUp.signedUpByUserId);
|
||||
return await _raidService.SignUpExternalUser(signUp.raidId, signUp.userName, signUp.roleId, SignUpType.Backup, signUp.signedUpByUserId);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Route("[action]")]
|
||||
public async Task SignUpFlex(ApiSignUp signUp)
|
||||
public async Task<bool> SignUpFlex(ApiSignUp signUp)
|
||||
{
|
||||
if(signUp.userId != 0)
|
||||
{
|
||||
int accountId = _userService.GetSignUpAccount(signUp.userId, signUp.raidId, signUp.gw2AccountId);
|
||||
await _raidService.SignUp(signUp.raidId, signUp.userId, accountId, signUp.roleId, SignUpType.Flex, signUp.signedUpByUserId);
|
||||
return await _raidService.SignUp(signUp.raidId, signUp.userId, accountId, signUp.roleId, SignUpType.Flex, signUp.signedUpByUserId);
|
||||
}
|
||||
else
|
||||
{
|
||||
await _raidService.SignUpExternalUser(signUp.raidId, signUp.userName, signUp.roleId, SignUpType.Flex, signUp.signedUpByUserId);
|
||||
return await _raidService.SignUpExternalUser(signUp.raidId, signUp.userName, signUp.roleId, SignUpType.Flex, signUp.signedUpByUserId);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Route("[action]")]
|
||||
public async Task SignOff(ApiSignUp signUp)
|
||||
public async Task<bool> SignOff(ApiSignUp signUp)
|
||||
{
|
||||
if(signUp.userId != 0)
|
||||
{
|
||||
|
@ -157,6 +157,7 @@ namespace Lieb.Controllers
|
|||
{
|
||||
await _raidService.SignOffExternalUser(signUp.raidId, signUp.userName, signUp.signedUpByUserId);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
|
|
|
@ -112,11 +112,11 @@ namespace Lieb.Data
|
|||
|
||||
}
|
||||
|
||||
public async Task SignUp(int raidId, ulong liebUserId, int guildWars2AccountId, int plannedRoleId, SignUpType signUpType, ulong signedUpByUserId = 0)
|
||||
public async Task<bool> SignUp(int raidId, ulong liebUserId, int guildWars2AccountId, int plannedRoleId, SignUpType signUpType, ulong signedUpByUserId = 0)
|
||||
{
|
||||
if (!IsRoleSignUpAllowed(raidId, liebUserId, plannedRoleId, signUpType, true))
|
||||
{
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
using var context = _contextFactory.CreateDbContext();
|
||||
|
||||
|
@ -134,14 +134,19 @@ namespace Lieb.Data
|
|||
await context.SaveChangesAsync();
|
||||
await LogSignUp(signUp, userName, signedUpByUserId);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
await _discordService.PostRaidMessage(raidId);
|
||||
return true;
|
||||
}
|
||||
|
||||
public async Task SignUpExternalUser(int raidId, string userName, int plannedRoleId, SignUpType signUpType, ulong signedUpByUserId)
|
||||
public async Task<bool> SignUpExternalUser(int raidId, string userName, int plannedRoleId, SignUpType signUpType, ulong signedUpByUserId)
|
||||
{
|
||||
if (!IsRoleSignUpAllowed(raidId, ulong.MaxValue, plannedRoleId, signUpType, true))
|
||||
{
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
using var context = _contextFactory.CreateDbContext();
|
||||
|
||||
|
@ -151,6 +156,7 @@ namespace Lieb.Data
|
|||
await context.SaveChangesAsync();
|
||||
await LogSignUp(signUp, userName, signedUpByUserId);
|
||||
await _discordService.PostRaidMessage(raidId);
|
||||
return true;
|
||||
}
|
||||
|
||||
public async Task SignOff(int raidId, ulong liebUserId, ulong signedOffByUserId = 0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue