public void Add(ShortenedUrl url) { using (var context = new UrlShortenerContext(_connectionString)) { context.ShortenedUrls.Add(url); context.SaveChanges(); } }
public async Task <ShortenedUrl> Insert(string url) { var entityToInsert = new ShortenedUrl { Url = url }; await _shortenedUrls.InsertOneAsync(entityToInsert); return(entityToInsert); }