public long?GetLastSavedTweetId(long userId) { using (var _context = new TweeterContext()) { return(_context.Tweet.Where(x => x.UserId == userId).Max(x => (long?)x.Id)); } }
public long[] GetTweetIds(long userId) { using (var _context = new TweeterContext()) { return(_context.Tweet.Where(x => x.UserId == userId).Select(x => x.Id).ToArray()); } }
public int AddTweets(List <Tweet> items) { var itemsAdded = 0; var ids = items.Select(x => x.Id).ToList(); using (var _context = new TweeterContext()) { var existsingIds = _context.Tweet.Where(x => ids.Contains(x.Id)).Select(x => x.Id).ToList(); items = items.Where(x => !existsingIds.Contains(x.Id)).ToList(); if (items.Count > 0) { _context.Tweet.AddRange(items); itemsAdded = _context.SaveChanges(); } } return(itemsAdded); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, TweeterContext context) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); app.UseMvc( routes => { routes.MapRoute("Default", "{controller=CoreUsers}/{action=getAll}/{id?}"); }); app.UseSwagger(); app.UseSwaggerUi(); // Dbinitializer.Initialize(context); }
public TweetersController(TweeterContext context) { _context = context; }