// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ReminderContext reminderContext) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } if (reminderContext.Database.ProviderName != "Microsoft.EntityFrameworkCore.InMemory") { reminderContext.Database.Migrate(); } app.UseSwagger(); app.UseSwaggerUI(c => { string swaggerJsonBasePath = string.IsNullOrWhiteSpace(c.RoutePrefix) ? "." : ".."; c.SwaggerEndpoint($"{swaggerJsonBasePath}/swagger/v1/swagger.json", _serviceName); }); if (Configuration["DevelopmentEnvironment"] != "local") { app.UseHttpsRedirection(); } app.UseRouting(); app.UseCors(c => c.AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader()); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }
public static List <Echeance> GetEcheances(int Ecart) { using (var db = new ReminderContext()) { return(db.Echeances.FromSqlRaw(@$ "exec PROC_ECHEANCE_RELANCE '{DateTime.Today.ToShortDateString()}', '{DateTime.Today.AddDays(Ecart).ToShortDateString()}', '{AppConfig.Config()[" Params: Source "]}'").ToList());
public ReminderController(ReminderContext context) { _context = context; if (_context.Reminders.Count() == 0) { _context.Reminders.Add(new Reminder(Name: "Reminder1", IsDone: false)); _context.SaveChanges(); } }
public ReminderController(ReminderContext context) { _context = context; if (_context.Reminders.Count() == 0) { // Create a new TodoItem if collection is empty, // which means you can't delete all TodoItems. _context.Reminders.Add(new Reminder { Title = "Reminder1" }); _context.SaveChanges(); } }
protected override void ConfigureWebHost(IWebHostBuilder builder) { builder.ConfigureServices(services => { var projectDir = Directory.GetCurrentDirectory(); var configPath = Path.Combine(projectDir, "appsettings-integration.json"); var config = new ConfigurationBuilder().AddJsonFile(configPath).Build(); services.AddSingleton <IConfiguration>(config); services.AddScoped <ReminderContext>(); // Build the service provider. var sp = services.BuildServiceProvider(); // Create a scope to obtain a reference to the database contexts using (var scope = sp.CreateScope()) { var scopedServices = scope.ServiceProvider; reminderDb = scopedServices.GetRequiredService <ReminderContext>(); var logger = scopedServices.GetRequiredService <ILogger <ReminderWebApplicationFactory <TStartup> > >(); try { // Seed the database with some specific test data. reminderDb.Reminders.DeleteMany(Builders <ReminderService.Models.Reminder> .Filter.Empty); reminderDb.Reminders.InsertMany(new List <ReminderService.Models.Reminder> { new ReminderService.Models.Reminder { UserId = "Jack", Email = "*****@*****.**", NewsReminders = new List <ReminderSchedule> { new ReminderSchedule { NewsId = 101, Schedule = DateTime.Now.AddDays(2) } } } }); } catch (Exception ex) { logger.LogError(ex, "An error occurred seeding the " + "database with test messages. Error: {ex.Message}"); } } }); }
public ReminderDbFixture() { var builder = new ConfigurationBuilder().AddJsonFile("appsettings.json"); configuration = builder.Build(); context = new ReminderContext(configuration); context.Reminders.DeleteMany(Builders <Reminder> .Filter.Empty); context.Reminders.InsertMany(new List <Reminder> { new Reminder { Id = 201, Name = "Sports", CreatedBy = "Mukesh", Description = "sports reminder", CreationDate = DateTime.Now, Type = "email" }, new Reminder { Id = 202, Name = "Politics", CreatedBy = "Mukesh", Description = "politics reminder", CreationDate = DateTime.Now, Type = "email" } }); }
public ReminderDbFixture() { var builder = new ConfigurationBuilder().AddJsonFile("appsettings.json"); configuration = builder.Build(); context = new ReminderContext(configuration); context.Reminders.DeleteMany(Builders <Reminder> .Filter.Empty); context.Reminders.InsertMany(new List <Reminder> { new Reminder { UserId = "Jack", Email = "*****@*****.**", NewsReminders = new List <ReminderSchedule> { new ReminderSchedule { NewsId = 101, Schedule = DateTime.Now } } } }); }
public void Dispose() { context = null; }
public ReminderJobRepository(ReminderContext context) { _context = context; }
public ReminderController(ReminderContext context) { _context = context; }
public ReminderIntegrationEventService(IEventBus eventBus, ReminderContext reminderContext) { _reminderContext = reminderContext ?? throw new ArgumentNullException(nameof(reminderContext)); _eventBus = eventBus ?? throw new ArgumentNullException(nameof(eventBus)); }
public ItemService(ReminderContext _context) { this._context = _context; }
public AuthorRepository(ReminderContext context) { _context = context; }
protected override void Dispose(bool disposing) { reminderDb.Reminders.DeleteMany(Builders <ReminderService.Models.Reminder> .Filter.Empty); reminderDb = null; }
public ReminderController(ReminderContext context) { _reminderContext = context ?? throw new ArgumentNullException(nameof(context)); context.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking; }
public ReminderRepository(ReminderContext reminderContext) { _reminderContext = reminderContext; }
public ReminderRepository(ReminderContext _context) { context = _context; }
public void Dispose() { context.Reminders.DeleteMany(Builders <Reminder> .Filter.Empty); context = null; }
public ReminderController(ReminderContext Context) { _itemService = new ItemService(Context); }