Example #1
0
        public static TodoWebAPIContext CreateTestingDatabase(string dbName)
        {
            var options = new DbContextOptionsBuilder <TodoWebAPIContext>().UseInMemoryDatabase(databaseName: dbName).Options;

            var dbContext = new TodoWebAPIContext(options);

            return(dbContext);
        }
Example #2
0
 public static void Seed(this TodoWebAPIContext context, List <TodoItem> mockTodoes = null)
 {
     if (mockTodoes != null)
     {
         context.TodoItem.AddRange(mockTodoes);
         context.SaveChanges();
     }
 }
Example #3
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            var RepoEF = new TodoWebAPIContext(Configuration);

            services
            .AddLogging()
            .AddDbContext <TodoWebAPIContext>()
            .AddSingleton <ITodoService, TodoService>()
            .AddSingleton <IPersonService, PersonService>()
            .AddSingleton <ITodoItemRepo, TodoWebAPIContext>()
            //.AddSingleton<IPersonRepo, PersonRepo>()
            .AddScoped <IPersonRepo, PersonRepo>()
            //.AddSingleton<IPersonRepo, TodoWebAPIContext>()
            //.AddScoped<ITodoItemRepo, TodoWebAPIRepoEF>()
            //.AddScoped<IPersonRepo, TodoWebAPIRepoEF>()
            .BuildServiceProvider();
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
        }
 public TodoPriorityTypesController(TodoWebAPIContext context)
 {
     _context = context;
 }
Example #5
0
 public TodoService(TodoWebAPIContext context)
 {
     _context = context;
 }