Ejemplo n.º 1
0
        public async Task <IActionResult> Index(UrlModel urlModel)
        {
            if (urlModel.ProvidedUrl == null)
            {
                return(View(_viewModel));
            }

            this._apiFactory            = new MercuryApiFactory(ApiUris.MercuryApiUri + urlModel.ProvidedUrl, ContentTypes.Json, ApiNames.MercuryApiName, AuthorizationTypes.xKey);
            this._httpRequestController = new HttpRequestController(_apiFactory.GetApi());
            this._httpRequestController.AddContentTypeHeader();
            this._httpRequestController.AddAutorizationHeader(_parser.GetObject(ApiNames.MercuryApiName));

            var result = await _httpRequestController.Send();

            var response = JsonConvert.DeserializeObject <ResponseModel>(result);

            if (response.content == null)
            {
                TempData["Error"] = "Site is not available or doesn't exist";
                return(View(_viewModel));
            }
            if (_viewModel.ResponseModels.Count == 5)
            {
                _viewModel.ResponseModels.RemoveAt(0);
            }
            _viewModel.ResponseModels.Insert(0, response);

            HtmlCounter counter = new HtmlCounter(_viewModel.ResponseModels.Last().content);

            _viewModel.ResponseModels.Last().TagsOccurrences = counter.CountOccurrence();


            return(View(_viewModel));
        }
Ejemplo n.º 2
0
        static void Main()
        {
            var factory = new ApiFactory();
            var api     = factory.GetApi();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainForm(api));
        }
Ejemplo n.º 3
0
 public async Task Upload_CheckRequestException()
 {
     var api = factory.GetApi(new HttpClient(), "http://noway");
     await Assert.ThrowsExceptionAsync <HttpRequestException>(() => api.Upload(token, null));
 }
Ejemplo n.º 4
0
 public Tests()
 {
     factory = new ApiFactory();
     api     = factory.GetApi(new HttpClient());
 }