예제 #1
0
        public Toy Add(string toyName, Child kid)
        {
            int id = _db.Insert($"INSERT INTO Toys(Name, ChildId) VALUES ('{toyName}', {kid.Id})");

            var toy = new Toy()
            {
                Id      = id,
                Name    = toyName,
                ChildId = kid.Id
            };

            _toys.Add(toy);

            return(toy);
        }
        public int AddChild(string child)
        {
            int id = _db.Insert($"insert into child values (null, '{child}', 0)");


            _children.Add(
                new Child()
            {
                id        = id,
                name      = child,
                delivered = false
            }
                );

            return(id);
        }
예제 #3
0
        public Toy Add(string toy, Child child)
        {
            // Insert into DB
            int newToyId = _db.Insert($"INSERT INTO toy VALUES (null, '{toy}', {child.id})");

            // Create new toy instance
            Toy newToy = new Toy()
            {
                id    = newToyId,
                name  = toy,
                child = child
            };

            // Add to private collection
            _toys.Add(newToy);

            return(newToy);
        }