コード例 #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();
     }
 }