コード例 #1
0
        public async Task <IServiceResult <string, ApiErrorModel> > GetSteamIdFromProfileUrlAsync(string url)
        {
            string steamId = string.Empty;

            try
            {
                steamId = await _steamService.Get64BitSteamIdAsync(url);

                _logger.Log(LogLevel.Debug, new EventId((int)LogEventId.General), $"SteamID for {url}: {steamId}");
            }
            catch (Exception ex)
            {
                //Type of error that is expected and should be relayed back to the client as a toast message
                _logger.Log(LogLevel.Error, new EventId((int)LogEventId.General), $"Failed to find Steam Id for {url}");
                _logger.Log(LogLevel.Error, new EventId((int)LogEventId.General), ex.ToString());
                var em = new ApiErrorModel()
                {
                    Errors = new List <string>()
                    {
                        $"No Steam profile found for {url}"
                    },
                    Type = ApiErrorModel.TYPE_TOAST_ERROR
                };

                return(ServiceResultFactory.Error <string, ApiErrorModel>(em));
            }
            return(ServiceResultFactory.Ok <string, ApiErrorModel>(steamId));
        }