Пример #1
0
 public long?GetLastSavedTweetId(long userId)
 {
     using (var _context = new TweeterContext())
     {
         return(_context.Tweet.Where(x => x.UserId == userId).Max(x => (long?)x.Id));
     }
 }
Пример #2
0
 public long[] GetTweetIds(long userId)
 {
     using (var _context = new TweeterContext())
     {
         return(_context.Tweet.Where(x => x.UserId == userId).Select(x => x.Id).ToArray());
     }
 }
Пример #3
0
        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);
        }
Пример #4
0
        // 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;
 }