Esempio n. 1
0
        static void Main(string[] args)
        {
            UserBase user1 = new UserBase();

            user1.Name        = "Petya";
            user1.DateOfBirth = new DateTime(1991, 01, 1).Date;
            user1.Id          = Guid.NewGuid();

            UserBase user2 = new UserBase();

            user2.Name        = "Vasya";
            user2.DateOfBirth = new DateTime(1992, 02, 2).Date;
            user2.Id          = Guid.NewGuid();

            UserBase user3 = new UserBase();

            user3.Name        = "Kolya";
            user3.DateOfBirth = new DateTime(1993, 03, 3).Date;
            user3.Id          = Guid.NewGuid();

            AwardBase award1 = new AwardBase();

            award1.Title = "Winner";
            award1.Id    = Guid.NewGuid();
            AwardBase award2 = new AwardBase();

            award2.Title = "Medallist";
            award2.Id    = Guid.NewGuid();
            AwardBase award3 = new AwardBase();

            award3.Title = "Participant";
            award3.Id    = Guid.NewGuid();

            UsersAwardsController controller = new UsersAwardsController();

            controller.AddNewUser(user1);
            controller.AddNewUser(user2);
            controller.AddNewUser(user3);

            controller.AddNewAward(award1);
            controller.AddNewAward(award2);
            controller.AddNewAward(award3);

            controller.AddAwardToUser(award1, user1);
            controller.AddAwardToUser(award2, user2);
            controller.AddAwardToUser(award3, user3);

            controller.SaveAllChanges();

            controller.DisplayUserInfo(user1);
            controller.DisplayUserInfo(user2);
            controller.DisplayUserInfo(user3);
            Console.WriteLine("===\nList of users:\n===");
            controller.DisplayUsersList();
            controller.DisplayAwardInfo(award1);

            Console.ReadLine();
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Console.WriteLine("=== Project Demo ===");

            // Create new users
            UserModel user1 = new UserModel();

            user1.Name        = "Dmitriy";
            user1.DateOfBirth = new DateTime(1989, 4, 7).Date;
            user1.Id          = Guid.NewGuid();

            UserModel user2 = new UserModel();

            user2.Name        = "Anna";
            user2.DateOfBirth = new DateTime(1996, 12, 12).Date;
            user2.Id          = Guid.NewGuid();

            UserModel user3 = new UserModel();

            user3.Name        = "Nico";
            user3.DateOfBirth = new DateTime(2001, 01, 20).Date;
            user3.Id          = Guid.NewGuid();

            // Create new awards
            AwardModel award1 = new AwardModel();

            award1.Title = "Gold";
            award1.Id    = Guid.NewGuid();
            AwardModel award2 = new AwardModel();

            award2.Title = "Silver";
            award2.Id    = Guid.NewGuid();
            AwardModel award3 = new AwardModel();

            award3.Title = "Bronse";
            award3.Id    = Guid.NewGuid();

            // Launch controller for working with users and awards
            UsersAwardsController controller = new UsersAwardsController();

            // Save users and awards to the JSON-storage
            controller.AddNewUser(user1);
            controller.AddNewUser(user2);
            controller.AddNewUser(user3);

            controller.AddNewAward(award1);
            controller.AddNewAward(award2);
            controller.AddNewAward(award3);

            controller.AddAwardToUser(award1, user1);
            controller.AddAwardToUser(award2, user1);
            controller.AddAwardToUser(award2, user2);
            controller.AddAwardToUser(award3, user3);

            controller.SaveAllChanges();

            // Show saved info
            controller.DisplayUserInfo(user1);
            controller.DisplayUserInfo(user2);
            controller.DisplayUserInfo(user3);
            Console.WriteLine("---");
            Console.WriteLine("User list: ");
            controller.DisplayUsersList();
            Console.WriteLine("---");
            controller.DisplayAwardInfo(award2);

            Console.ReadLine();
        }