Ejemplo n.º 1
0
        public async Task <IHttpActionResult> Post([FromBody] Link entity)
        {
            logger.Trace("Call LinksController Post");

            var record = await linkRepository.CreateAsync(entity);

            return(Created(record));
        }
Ejemplo n.º 2
0
        public async Task <LinkResult> CreateNewLink(string clientId, string redirectUrl)
        {
            var link = await _linkRepository.CreateAsync(clientId, redirectUrl);

            return(new LinkResult {
                Url = GetLinkUrl(link.Key), RedirectUrl = redirectUrl
            });
        }
Ejemplo n.º 3
0
        public async Task <LinkShortDTO> CreateLink(string link, string clientKey)
        {
            var clientId = (await _clientRepository.FirstOrDefaultAsync(x => x.ClientKey == clientKey))?.Id ?? 0;

            if (clientId == 0)
            {
                clientId = await AddClient(clientKey);
            }
            var linkObj = new Link
            {
                ClientId     = clientId,
                CreationDate = DateTime.Now,
                OriginalLink = link,
                Id           = _idGenerator.GetId()
            };
            await _linkRepository.CreateAsync(linkObj);

            return(new LinkShortDTO
            {
                OriginalLink = link,
                Hash = linkObj.Id,
                ShortLink = _preferences.CurrentDomain + linkObj.Id
            });
        }