Example #1
0
        public async Task <ActionResult> LookupCode(string code)
        {
            var shrtUrlEntity = await _shrtUrlRepo.LookupShrtUrl(code);

            if (shrtUrlEntity == null)
            {
                return(new NotFoundResult());
            }

            await _shrtUrlRepo.IncrementClicks(shrtUrlEntity);

            return(new RedirectResult(shrtUrlEntity.Url));
        }
Example #2
0
        public async Task <ActionResult> GetStats(string code)
        {
            if (code == null)
            {
                return(new BadRequestResult());
            }

            var shrtUrlEntity = await _shrtnUrlRepo.LookupShrtUrl(code);

            if (shrtUrlEntity == null)
            {
                return(new NotFoundResult());
            }

            return(new OkObjectResult(new ShrtUrlDto().FromShrtUrlEntity(shrtUrlEntity)));
        }