Esempio n. 1
0
        public async Task <ServiceResponse <TwitterUser> > GetUser(string screenName)
        {
            var user = new TwitterUser();

            try
            {
                if (_connectivityService.IsConnected)
                {
                    var dto = await _twitterApi.GetUser(screenName);

                    user = Mapper.Map <TwitterUser> (dto);

                    return(new ServiceResponse <TwitterUser>(user, ServiceResponseType.SUCCESS));
                }
                else
                {
                    return(new ServiceResponse <TwitterUser>(user, ServiceResponseType.NO_CONNECTION));
                }
            }
            catch (BaseException e)
            {
                return(new ServiceResponse <TwitterUser>(user, ServiceResponseType.ERROR));
            }
            catch (Exception exception)
            {
                _logger.Log(new ServiceException("Error getting Twitter user", exception), LogType.ERROR);
                return(new ServiceResponse <TwitterUser>(user, ServiceResponseType.ERROR));
            }
        }