public static async Task <TwitterApiResponse <bool> > IsNameAvailable(string screenName) { TwitterApiResponse <bool> response = new TwitterApiResponse <bool>(); response.Content = true; try { var ctx = new TwitterContext(new SingleUserAuthorizer { CredentialStore = GetCredentials() }); var query = await( from search in ctx.User where search.Type == UserType.Show && search.ScreenName == screenName select search).SingleOrDefaultAsync(); if (query != null) { response.Content = false; var name = query.ScreenNameResponse; var lastStatus = query.Status == null ? "No Status" : query.Status.Text; } } catch (TwitterQueryException ex) { response.Content = ex.StatusCode == System.Net.HttpStatusCode.NotFound ? true : false; response.Error = CreateError(ex); } return(response); }
// GET: Monitoring public async Task <ActionResult> Index() { var model = new MonitoringViewModel(); TwitterApiResponse <Dictionary <string, RateLimit> > response = await TwitterApiManager.GetRateLimits(); model.RateLimits = response.Content; try { model.LastNameChecks = await NameCheckDataService.GetCollectionAsync(); model.LastNameCheckBatches = await NameCheckBatchDataService.GetCollectionAsync(); } catch (Exception ex) { model.Error = ex; } model.Configuration = ReadConfiguration(); return(View(model)); }