Example #1
0
        private void SetAsSubunit(string parentName, AdministrativeType parentType, string childName, AdministrativeType childType)
        {
            var parent = store.Units.Of(parentType).FindByName(parentName);

            if (parent == null)
            {
                Console.WriteLine($"No unit with name {parentName}\n");
                return;
            }

            var child = store.Units.Of(childType).FindByName(childName);

            if (child == null)
            {
                Console.WriteLine($"No unit with name {childName}\n");
                return;
            }

            if (parent.CanAddAsSubunit(child))
            {
                parent.AddSubunit(child);
                Console.WriteLine($"Add subunit {childName} to {parentName}\n");
                return;
            }
            Console.WriteLine($"Cannot add {childName} as subunit of {parentName}\n");
            Console.WriteLine("If you have unit with same name try to specify type");
        }
Example #2
0
 public StorageData Of(AdministrativeType type)
 {
     Data = Data.Where(unit => (unit.Type & type) != 0);
     return(this);
 }