public async Task <BasketCart> UpdateBasket(BasketCart basketCart) { var update = await _contest.AddAsync(basketCart.UserName, JsonConvert.SerializeObject(basketCart)); if (!update) { return(null); } return(await GetBasketCart(basketCart.UserName)); }
public async Task <QrResponseModel> ScanQrAsync(string qrPath) { _logger.LogTrace($"{TAG} ScanQrAsync called with path: {qrPath}"); if (string.IsNullOrWhiteSpace(qrPath)) { throw new ArgumentException("The path cannot be null or empty."); } var cacheKey = new QrCacheKey(qrPath); var cachedResponse = await _cacheStore.GetAsync <QrResponseModel>(cacheKey); if (cachedResponse != null) { _logger.LogTrace($"{TAG} Returning response found in cache."); return(cachedResponse); } QrFileModel file = null; try { file = await _provider.ProvideQrAsync(qrPath); } catch (Exception e) { _logger.LogError($"{TAG} Provider call failed. Reason: '{e.Message}'."); throw; } QrResponseModel result = null; try { result = await _client.PostQrAsync(file); } catch (Exception e) { _logger.LogError($"{TAG} QR api call failed. Reason: '{e.Message}'."); throw; } await _cacheStore.AddAsync(cacheKey, result); return(result); }