示例#1
0
 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());
     }
 }
示例#2
0
 public async Task <Shorten> GetShortenByShortedUrlAsync(string shortedUrl)
 {
     using (var context = new ShortenDbContext())
     {
         return(await context.Shortens.FirstOrDefaultAsync(s => s.ShortedUrl.Equals(shortedUrl)));
     }
 }
示例#3
0
 public async Task UpdateAsync(Shorten shorten)
 {
     using (var context = new ShortenDbContext())
     {
         context.Entry(shorten).State = EntityState.Modified;
         await context.SaveChangesAsync();
     }
 }
示例#4
0
 public async Task SaveAsync(Shorten shorten)
 {
     using (var context = new ShortenDbContext())
     {
         context.Shortens.Add(shorten);
         await context.SaveChangesAsync();
     }
 }