using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;

namespace UWLib
{
    public class LectureContext : DbContext
    {
        public DbSet<Lecture> Lectures { get; set; }    
        public DbSet<LectureEvent> LectureEvents { get; set; }

        public DbSet<ScrapedLink> ScrapedLinks { get; set; }

        public DbSet<LinkToScrape> LinksToScrape { get; set; }


        public string DbPath { get; }


        public LectureContext(string path) 
        {
            DbPath = path;
            Database.Migrate();
        }

        public LectureContext()
        {
            var folder = Environment.SpecialFolder.LocalApplicationData;
            var path = Environment.GetFolderPath(folder);
            DbPath = System.IO.Path.Join(path, "lecture.db");
            DbPath = "lecture.db";

            Database.Migrate();
        }

        // The following configures EF to create a Sqlite database file in the
        // special "local" folder for your platform.
        protected override void OnConfiguring(DbContextOptionsBuilder options)
            => options.UseSqlite($"Data Source={DbPath}");

    }
}
