public static TodoWebAPIContext CreateTestingDatabase(string dbName) { var options = new DbContextOptionsBuilder <TodoWebAPIContext>().UseInMemoryDatabase(databaseName: dbName).Options; var dbContext = new TodoWebAPIContext(options); return(dbContext); }
public static void Seed(this TodoWebAPIContext context, List <TodoItem> mockTodoes = null) { if (mockTodoes != null) { context.TodoItem.AddRange(mockTodoes); context.SaveChanges(); } }
// 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; }
public TodoService(TodoWebAPIContext context) { _context = context; }