Beispiel #1
0
        public ActionResult <Response <string> > GetFullUrlByShortUrl([FromQuery] string shortUrl)
        {
            string        fullUrl = "";
            List <string> errors  = new List <string>();

            if (string.IsNullOrWhiteSpace(shortUrl))
            {
                errors.Add("Параметр url не должен быть пустым");
            }

            if (errors.Count == 0)
            {
                Link link = _linkService.GetByUrlShort(shortUrl);
                if (link != null)
                {
                    fullUrl = link.FullUrl;
                    link.СlickThroughs++;
                    _linkService.Update(link.Id, link);
                }
                else
                {
                    errors.Add("По данному url ничего не найдено");
                }
            }

            return(new Response <string>()
            {
                Errors = errors,
                Object = fullUrl
            });
        }