Skip to content

Commit

Permalink
Add null checks
Browse files Browse the repository at this point in the history
  • Loading branch information
bolatovumar committed Aug 28, 2022
1 parent 45ce6d1 commit 2ee4539
Showing 1 changed file with 8 additions and 2 deletions.
Expand Up @@ -126,7 +126,7 @@ public async Task<IActionResult> ContributeToCrowdfund(string appId, ContributeT
if (!string.IsNullOrEmpty(request.ChoiceKey))
{
var choices = _appService.GetPOSItems(settings.PerksTemplate, settings.TargetCurrency);
choice = choices.FirstOrDefault(c => c.Id == request.ChoiceKey);
choice = choices?.FirstOrDefault(c => c.Id == request.ChoiceKey);
if (choice == null)
return NotFound("Incorrect option provided");
title = choice.Title;
Expand Down Expand Up @@ -379,7 +379,13 @@ private async Task<string> GetStoreDefaultCurrentIfEmpty(string storeId, string
{
if (string.IsNullOrWhiteSpace(currency))
{
currency = (await _storeRepository.FindStore(storeId)).GetStoreBlob().DefaultCurrency;
var store = await _storeRepository.FindStore(storeId);
if (store == null)
{
throw new Exception($"Could not find store with id {storeId}");
}

currency = store.GetStoreBlob().DefaultCurrency;
}
return currency.Trim().ToUpperInvariant();
}
Expand Down

0 comments on commit 2ee4539

Please sign in to comment.