示例#1
0
        // 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(); });
        }
示例#2
0
 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());
示例#3
0
        public ReminderController(ReminderContext context)
        {
            _context = context;

            if (_context.Reminders.Count() == 0)
            {
                _context.Reminders.Add(new Reminder(Name: "Reminder1", IsDone: false));
                _context.SaveChanges();
            }
        }
示例#4
0
        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}");
                    }
                }
            });
        }
示例#6
0
        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"
                }
            });
        }
示例#7
0
        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
                        }
                    }
                }
            });
        }
示例#8
0
 public void Dispose()
 {
     context = null;
 }
示例#9
0
 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));
 }
示例#12
0
 public ItemService(ReminderContext _context)
 {
     this._context = _context;
 }
示例#13
0
 public AuthorRepository(ReminderContext context)
 {
     _context = context;
 }
 protected override void Dispose(bool disposing)
 {
     reminderDb.Reminders.DeleteMany(Builders <ReminderService.Models.Reminder> .Filter.Empty);
     reminderDb = null;
 }
示例#15
0
        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;
 }
示例#18
0
 public void Dispose()
 {
     context.Reminders.DeleteMany(Builders <Reminder> .Filter.Empty);
     context = null;
 }
示例#19
0
 public ReminderController(ReminderContext Context)
 {
     _itemService = new ItemService(Context);
 }