示例#1
0
        public static void Action(ToyRegister bag, ChildrenRegister book)
        {
            Console.Clear();
            Console.WriteLine("Show bag of loot for which child?");

            var children = book.GetChildren();

            foreach (var child in children)
            {
                Console.WriteLine($"{child.Id}: {child.Name}");
            }
            Console.Write("> ");

            var childId = int.Parse(Console.ReadLine());

            var kid = book.GetChild(childId);

            var toys = bag.GetToysForChild(kid);

            Console.Clear();
            Console.WriteLine($"{kid.Name}'s Bag o' loot");
            Console.WriteLine(new string('-', 30));
            foreach (var toy in toys)
            {
                Console.WriteLine($"{toy.Name}");
            }
            Console.ReadLine();
        }
示例#2
0
        public static void Action(ToyRegister bag, ChildrenRegister book)
        {
            Console.Clear();
            Console.WriteLine("Choose a child");

            var children = book.GetChildren();

            foreach (var child in children)
            {
                Console.WriteLine($"{child.Id}: {child.Name}");
            }

            int childId = int.Parse(Console.ReadLine());

            var kid = book.GetChild(childId);

            Console.WriteLine($"Choose a toy to revoke from {kid.Name}");
            Console.Write("> ");
            var kidsToys = bag.GetToysForChild(kid);

            foreach (var toy in kidsToys)
            {
                Console.WriteLine($"{toy.Id}: {toy.Name}");
            }

            int toyId       = int.Parse(Console.ReadLine());
            var toyToRevoke = kidsToys.First(t => t.Id == toyId);

            bag.RevokeToy(toyToRevoke, kid);
        }
示例#3
0
 public ToyRegisterShould()
 {
     _db       = new DatabaseInterface("BAGOLOOT_TEST_DB");
     _register = new ToyRegister(_db);
     _book     = new ChildRegister(_db);
     _db.CheckChildTable();
     _db.CheckToyTable();
 }
示例#4
0
        public static void DoAction(ToyRegister bag, ChildRegister book)
        {
            Console.Clear();
            Console.WriteLine("Choose child");

            List <Child> children = book.GetChildren();

            foreach (Child child in children)
            {
                Console.WriteLine($"{child.id}. {child.name}");
            }

            Console.Write("> ");
            string childName = Console.ReadLine();
            Child  kid       = book.GetChild(int.Parse(childName));

            Console.WriteLine("Enter toy");
            Console.Write("> ");
            string toyName = Console.ReadLine();

            bag.Add(toyName, kid);
        }
示例#5
0
        public static void Action(ToyRegister toyRegister, ChildrenRegister childRegister)
        {
            Console.Clear();
            Console.WriteLine("Choose a child");

            var children = childRegister.GetChildren();

            foreach (var child in children)
            {
                Console.WriteLine($"{child.Id}: {child.Name}");
            }

            Console.Write("> ");
            int childId = int.Parse(Console.ReadLine());

            var kid = childRegister.GetChild(childId);

            Console.WriteLine("Enter a toy");
            Console.Write("> ");
            string toyName = Console.ReadLine();

            toyRegister.Add(toyName, kid);
        }
        public static void Action(ToyRegister bag, ChildrenRegister book)
        {
            Console.Clear();
            Console.WriteLine("YULETIME DELIVERY REPORT");
            Console.WriteLine(new string('%', 30));
            var childrenDelivered = book.GetChildren();

            childrenDelivered = childrenDelivered.Where(c => c.Delivered);

            foreach (var child in childrenDelivered)
            {
                Console.WriteLine($"{child.Name}");
                var toys = bag.GetToysForChild(child);
                foreach (var toy in toys)
                {
                    Console.WriteLine("  " + $"{toy.Name}");
                }
                Console.WriteLine();
            }



            Console.ReadLine();
        }