Ejemplo n.º 1
0
        public async Task <ApplicationResponse <ShortUrlResponseDto> > Get(string shortUrl)
        {
            var encodeUrl = WebUtility.UrlEncode(shortUrl);

            var entityShortUrl = await _shortUrlRepository.GetAsync(url => url.ShortUrlValue.Equals(encodeUrl));

            if (entityShortUrl.ExpireDate <= DateTime.Now)
            {
                return(new ApplicationResponse <ShortUrlResponseDto>(ResponseState.Error, "Url is expired"));
            }

            var result = UrlShortMapper.Map(entityShortUrl);

            return(new ApplicationResponse <ShortUrlResponseDto>(result));
        }