public async Task <List <Shorten> > GetShortenUrlsAsync(string[] rawUrls) { using (var context = new ShortenDbContext()) { return(await context.Shortens.Where(s => rawUrls.Contains(s.RawUrl)).OrderByDescending(o => o.CreateDate).ToListAsync()); } }
public async Task <Shorten> GetShortenByShortedUrlAsync(string shortedUrl) { using (var context = new ShortenDbContext()) { return(await context.Shortens.FirstOrDefaultAsync(s => s.ShortedUrl.Equals(shortedUrl))); } }
public async Task UpdateAsync(Shorten shorten) { using (var context = new ShortenDbContext()) { context.Entry(shorten).State = EntityState.Modified; await context.SaveChangesAsync(); } }
public async Task SaveAsync(Shorten shorten) { using (var context = new ShortenDbContext()) { context.Shortens.Add(shorten); await context.SaveChangesAsync(); } }