Example #1
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Libraries              libraries      = new Libraries();
            TitlesDBRepository     repoTitles     = new TitlesDBRepository("DESKTOP-E94DLUN\\SQLEXPRESS", "Libraries");
            CharactersDBRepository repoCharacters = new CharactersDBRepository("DESKTOP-E94DLUN\\SQLEXPRESS", "Libraries");

            OneToManyService <int, Title, int, Character> service = new OneToManyService <int, Title, int, Character>(repoTitles, repoCharacters, new CharacterValidator());

            libraries.MyService = service;
            Console.WriteLine("bla");
            Application.Run(libraries);
        }
Example #2
0
        static void testService()
        {
            TitlesDBRepository     repoTitles     = new TitlesDBRepository("DESKTOP-E94DLUN\\SQLEXPRESS", "Libraries");
            CharactersDBRepository repoCharacters = new CharactersDBRepository("DESKTOP-E94DLUN\\SQLEXPRESS", "Libraries");

            OneToManyService <int, Title, int, Character> service = new OneToManyService <int, Title, int, Character>(repoTitles, repoCharacters, new CharacterValidator());

            foreach (Title title in service.GetParents())
            {
                Console.WriteLine(title);
            }
            Console.WriteLine();

            foreach (Character character in service.GetRecordsForParentId(1))
            {
                Console.WriteLine(character);
            }
            Console.WriteLine();

            service.Add(new Character(4, 2, "char1", "Primary"));

            foreach (Character character in service.GetRecordsForParentId(2))
            {
                Console.WriteLine(character);
            }
            Console.WriteLine();

            service.Update(new Character(4, 2, "char1 updated", "Secondary"));

            foreach (Character character in service.GetRecordsForParentId(2))
            {
                Console.WriteLine(character);
            }
            Console.WriteLine();

            service.Remove(4);

            foreach (Character character in service.GetRecordsForParentId(2))
            {
                Console.WriteLine(character);
            }
            Console.WriteLine();
        }
Example #3
0
        static void Main()
        {
            string database         = ConfigurationManager.AppSettings.Get("database");
            string server           = ConfigurationManager.AppSettings.Get("server");
            string parentTable      = ConfigurationManager.AppSettings.Get("parentTable");
            string childTable       = ConfigurationManager.AppSettings.Get("childTable");
            string parentPrimaryKey = ConfigurationManager.AppSettings.Get("parentPrimaryKey");

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Libraries libraries = new Libraries(parentTable, childTable);

            DBRepository parentRepo = new DBRepository(server, database, parentTable);
            DBRepository childRepo  = new DBRepository(server, database, childTable);

            OneToManyService service = new OneToManyService(parentRepo, childRepo, parentPrimaryKey);

            libraries.MyService = service;

            Application.Run(libraries);
        }