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"); }
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()); } }
public static void AddNews(List <ItemNews> news) { using (RssDbContext dbContext = new RssDbContext()) { dbContext.News.AddRange(news); dbContext.SaveChanges(); } }
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(); }
public UserRepository(RssDbContext dbContext, IConfiguration Configuration) : base(dbContext) { db = dbContext; config = Configuration; }
public NewsAJAXController(RssDbContext context) { _context = context; }