示例#1
0
 public void LoadData()
 {
     var user   = _security.AddUser("TestUser", "*****@*****.**", "SamePassword");
     var apiKey = _security.AddApiKey(user);
     var url1   = _urlService.AddUrl("https://www.typescriptlang.org/docs/handbook/modules.html", user);
     var url2   = _urlService.AddUrl("https://habrahabr.ru/company/newprolab/blog/351616/", user);
 }
        public async Task ProcessUrl(string strUrl)
        {
            string connectionId = Context.ConnectionId;

            await _service.AddUrl(strUrl, connectionId);

            //Clients.Caller.Item(dto.page, dto.timeTaken);
        }
示例#3
0
        public IActionResult Create([FromBody] string url)
        {
            var user = GetUser();

            if (user == null)
            {
                RedirectToAction("Login");
            }

            var newUrl = _urlService.AddUrl(url, user);

            return(RedirectToAction("Index"));
        }
示例#4
0
        public async Task <IActionResult> Post(UrlCreate url)
        {
            try
            {
                var result = await _urlService.AddUrl(url);

                return(Ok(result));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Error in Post", new Object[] { url });
                throw;
            }
        }
        public IActionResult ShortenUrl(string originalUrl)
        {
            if (!ModelState.IsValid)
            {
                return(View("Index"));
            }
            string shortKey = _urlService.GetShortKeyForOriginalUrl(originalUrl);

            _urlService.AddUrl(originalUrl, shortKey);
            var userId = 1;

            ViewData["UserUrlList"] = _userService.GetUserUrlList(userId);

            return(View("Index"));
        }
示例#6
0
 public IActionResult addUrl(string Url)
 {
     if (!String.IsNullOrEmpty(Url))
     {
         var isExcept = _urlService.isExcept(Url);
         if (isExcept == false)
         {
             return(Ok(false));
         }
         var isOk = _urlService.AddUrl(Url);
         if (isOk == true)
         {
             return(Ok(true));
         }
         else
         {
             return(Ok(false));
         }
     }
     else
     {
         return(Ok(false));
     }
 }