Esempio n. 1
0
        public async Task <IActionResult> Comic(int code)
        {
            //get data from remote using comic service
            var response = await _service.GetComicByCode(code, GeneralSettings.Instance.ComicUrlTpl);


            if (response.Success)
            {
                var model = response.GetData <WebComic>();

                _logger.LogInformation($"Getting remote resource is completed!. Sending Data to User -> Comic:{model.Num} {(model.IsTodayComic ? "-> Is Today's Comic" : "")}");
                return(View(model));
            }
            else
            {
                //built the next or prev num code comic
                code += (response.NextAction ? 1 : -1);

                //write info into log
                _logger.LogInformation($"Response Status: {response.StatusCode}. Comic Resource was not found! Redirect to {code} Comic.");

                //Redirect to next or previous comic resource
                return(RedirectToAction("Comic", new { code = code })); //Redirect to next or previous comic
            }
        }
Esempio n. 2
0
        public void GetComicByCodeTest()
        {
            WebComicService svc      = new WebComicService();
            var             response = svc.GetComicByCode(1, COMIC_URL_TPL).Result;

            Assert.IsTrue(response.Success);
        }