예제 #1
0
        public async Task <IActionResult> GenerateShortUrl(string newUrl)
        {
            if (!string.IsNullOrWhiteSpace(newUrl))
            {
                return(Content("The specified Url is wrong"));
            }

            //var response = new UrlAddResponse();
            var urlVm = new UrlViewModels();

            var response = await _urlService.AddUrlAsync(newUrl);

            if (response.IsSuccess == false)
            {
                urlVm.Message = response.Message;
                return(RedirectToAction("Index", urlVm));
            }
            urlVm             = BuildUrlVm(response);
            urlVm.OriginalUrl = newUrl;
            return(RedirectToAction("Index", urlVm));
        }