コード例 #1
0
        public async Task <IActionResult> Get(Guid watchlistId)
        {
            _logger.LogInformation("Getting all items");
            try
            {
                var watchlists = await _watchlistsService.GetWatchlist(watchlistId);

                return(Ok(_mapper.Map <ICollection <Item> >(watchlists.Items)));
            }
            catch (Exception ex)
            {
                _logger.LogError($"{_localizer["Failed to get all items"]}", ex);
                return(BadRequest());
            }
        }
コード例 #2
0
        public async Task <IActionResult> Get(Guid userId)
        {
            _logger.LogInformation($"Getting watchlist for user {userId}");
            try
            {
                var watchlist = await _watchlistsService.GetWatchlist(userId);

                return(Ok(watchlist));
            }
            catch (Exception ex)
            {
                _logger.LogError($"Failed to get watchlist for user {userId}" + ex);
                return(BadRequest());
            }
        }
コード例 #3
0
        public async Task <IActionResult> Get(Guid id)
        {
            _logger.LogInformation($"Getting watchlist by Id = {id}");
            try
            {
                var watchlist = await _watchlistsService.GetWatchlist(id);

                if (watchlist != null)
                {
                    return(Ok(_mapper.Map <Watchlist>(watchlist)));
                }
                else
                {
                    return(NotFound());
                }
            }
            catch (Exception ex)
            {
                _logger.LogError($"Failed to get watchlist with Id = {id}", ex);
                return(BadRequest());
            }
        }