Exemplo n.º 1
0
        public static async Task RunAsync(CancellationToken cancellationToken)
        {
            Console.WriteLine("Create database command");

            var config = new ConfigurationBuilder()
                         .SetBasePath(Directory.GetCurrentDirectory())
                         .AddJsonFile("appsettings.json")
                         .Build();

            var connection = config.GetConnectionString("DefaultConnection");
            var context    = new RssDbContext(connection);

            Console.WriteLine($"Connection string: {connection} \n Type 'yes' to continue");

            if (Console.ReadLine() != "yes")
            {
                return;
            }

            await context.Database.EnsureDeletedAsync(cancellationToken);

            var success = await context.Database.EnsureCreatedAsync(cancellationToken);

            if (!success)
            {
                throw new InvalidOperationException();
            }

            Console.WriteLine("SUCCESS");
        }
Exemplo n.º 2
0
 public static ItemNews GetLastNews(string siteNews)
 {
     using (RssDbContext dbContext = new RssDbContext())
     {
         var intefaxNews = dbContext.News.OrderByDescending(e => e.PublishDate).Where(e => e.Link.Contains(siteNews));
         return(intefaxNews.FirstOrDefault());
     }
 }
Exemplo n.º 3
0
 public static void AddNews(List <ItemNews> news)
 {
     using (RssDbContext dbContext = new RssDbContext())
     {
         dbContext.News.AddRange(news);
         dbContext.SaveChanges();
     }
 }
Exemplo n.º 4
0
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, RssDbContext dataContext)
        {
            app.UseCors("AllowAllHeaders");

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseRouting();

            app.UseAuthentication();
            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
                endpoints.MapHub <WebrtcSignalingHub>("/signaling");
            });

            app.UseSwagger();
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "Rss Sata.uz");
                c.DefaultModelExpandDepth(2);
                c.DefaultModelRendering(ModelRendering.Model);
                c.DefaultModelsExpandDepth(-1);
                c.DisplayOperationId();
                c.DisplayRequestDuration();
                c.DocExpansion(DocExpansion.None);
                c.EnableDeepLinking();
                c.EnableFilter();
                c.MaxDisplayedTags(5);
                c.ShowExtensions();
                c.EnableValidator();
                c.SupportedSubmitMethods(SubmitMethod.Get, SubmitMethod.Post, SubmitMethod.Delete, SubmitMethod.Put, SubmitMethod.Head);
            });

            app.UseExtCore();
        }
Exemplo n.º 5
0
 public UserRepository(RssDbContext dbContext, IConfiguration Configuration) : base(dbContext)
 {
     db     = dbContext;
     config = Configuration;
 }
 public NewsAJAXController(RssDbContext context)
 {
     _context = context;
 }