public async Task <string> AddURL(URLShortenerDTO urlShortenerDTO) { urlManagementDbContext.ShrotenerURLs.Add( new ShrotenerURL { ConvertedURL = urlShortenerDTO.ConvertedURL, MainURL = urlShortenerDTO.MainURL }); await urlManagementDbContext.SaveChangesAsync(); return(await Task.FromResult(urlShortenerDTO.ConvertedURL)); }
public URLShortenerDTO ObterUrls(int page, string search) { page = page - 1; if (string.IsNullOrEmpty(search)) { search = ""; } URLShortenerDTO retorno = new URLShortenerDTO(); var links = _context.Urls.Where(x => x.Nome.Contains(search)).Skip(page * 25).Take(25).OrderBy(x => x.DT_Criacao).ToList(); retorno.URLShorteners = links; retorno.Count = _context.Urls.Where(x => x.Nome.Contains(search)).Count(); return(retorno); }