Added style guidance and performed enforcement
This commit is contained in:
@ -49,8 +49,6 @@ namespace IO.Swagger.Controllers
|
||||
this.mapper = mapper ?? throw new ArgumentNullException(nameof(mapper));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get user's wallet balances
|
||||
/// </summary>
|
||||
@ -64,12 +62,12 @@ namespace IO.Swagger.Controllers
|
||||
[ProducesResponseType(typeof(IEnumerable<WalletBalanceDto>), 200)]
|
||||
public virtual async Task<IActionResult> GetUserBalances()
|
||||
{
|
||||
var userIdString = HttpContext.User.Claims.First(c => c.Type == ClaimTypes.NameIdentifier).Value;
|
||||
string userIdString = HttpContext.User.Claims.First(c => c.Type == ClaimTypes.NameIdentifier).Value;
|
||||
if (!int.TryParse(userIdString, out int userId))
|
||||
return Unauthorized();
|
||||
|
||||
var balances = await transactionRepository.GetBalancesForUser(userId);
|
||||
var res = balances.Select(t => new WalletBalanceDto
|
||||
List<Tuple<Models.db.Currency, float>> balances = await transactionRepository.GetBalancesForUser(userId);
|
||||
IEnumerable<WalletBalanceDto> res = balances.Select(t => new WalletBalanceDto
|
||||
{
|
||||
Currency = mapper.Map<CurrencyDto>(t.Item1),
|
||||
Balance = t.Item2
|
||||
@ -90,11 +88,11 @@ namespace IO.Swagger.Controllers
|
||||
[ProducesResponseType(typeof(IEnumerable<TransactionDto>), 200)]
|
||||
public virtual async Task<IActionResult> GetUserTransactions()
|
||||
{
|
||||
var userIdString = HttpContext.User.Claims.First(c => c.Type == ClaimTypes.NameIdentifier).Value;
|
||||
string userIdString = HttpContext.User.Claims.First(c => c.Type == ClaimTypes.NameIdentifier).Value;
|
||||
if (!int.TryParse(userIdString, out int userId))
|
||||
return Unauthorized();
|
||||
|
||||
var transactions = await transactionRepository.GetTransactionsForUser(userId);
|
||||
List<Models.db.Transaction> transactions = await transactionRepository.GetTransactionsForUser(userId);
|
||||
return Ok(transactions.Select(mapper.Map<TransactionDto>));
|
||||
}
|
||||
|
||||
@ -140,14 +138,14 @@ namespace IO.Swagger.Controllers
|
||||
[ProducesResponseType(typeof(TransactionReturnCode), 409)]
|
||||
public virtual async Task<IActionResult> TransferPhysicalCurrency([FromBody] WalletTransferPhysicalBody body)
|
||||
{
|
||||
var userIdString = HttpContext.User.Claims.First(c => c.Type == ClaimTypes.NameIdentifier).Value;
|
||||
string userIdString = HttpContext.User.Claims.First(c => c.Type == ClaimTypes.NameIdentifier).Value;
|
||||
if (!int.TryParse(userIdString, out int userId))
|
||||
return Unauthorized();
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(ModelState.Values.SelectMany(v => v.Errors.Select(e => e.ErrorMessage)));
|
||||
|
||||
var transactionResult = await transactionRepository.TransferPhysical(body, userId);
|
||||
return transactionResult == TransactionReturnCode.Success ? Ok() : StatusCode(409, (int)transactionResult);
|
||||
TransactionReturnCode transactionResult = await transactionRepository.TransferPhysical(body, userId);
|
||||
return transactionResult == TransactionReturnCode.Success ? Ok() : StatusCode(409, (int) transactionResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user