public static Queen Create() { Caption.Title("Add Queen"); var queen = new Queen(); queen.Name = Ask.String("Name"); queen.AgeInDays = Ask.Value("Age in Days"); return(queen); }
public async static Task List() { Caption.Title("View All Queens"); List <Queen> queens = await Context.Get.Queens.ToListAsync(); if (queens.Count == 0) { Console.WriteLine("There are no Queens"); return; } ListView.Print(queens); }
public static async Task <Ant> Create() { Caption.Title("Add Ant"); List <Hive> hives = await Context.Get.Hives.ToListAsync(); if (hives.Count == 0) { Caption.Error("You cannot add Ants without a Hive"); return(null); } var ant = new Ant(); Console.WriteLine("Add a new Ant"); ant.Name = Ask.String("Name"); ant.AgeInDays = Ask.Value("Age in Days"); ant.FavoriteAntGame = Ask.String("Favourite Game"); return(ant); }
public static async Task List() { Caption.Title("All Hives"); List <Hive> hives = await Context.Get.Hives.ToListAsync(); if (hives.Count == 0) { Console.WriteLine("No Hives Found"); return; } hives.ForEach(hive => { Console.WriteLine(hive); Console.WriteLine($" => owned by queen {hive.Queen.Name}"); Console.WriteLine($" => has {hive.Ants.Count} ants"); ListView.Print(hive.Ants, " => "); Console.WriteLine(); }); }
public static async Task <Hive> Create() { Caption.Title("Add Hive"); List <Queen> queens = await Context.Get.Queens.ToListAsync(); if (queens.Count == 0) { Console.WriteLine("You cannot create a hive without a queen!"); return(null); } ListView.Print(queens); var hive = new Hive(); var queenID = Ask.Value("Queen ID"); hive.Queen = Context.Get.Queens.Find(queenID); hive.Name = Ask.String("Name"); return(hive); }
private async static void AddAnt() { var ant = await AntView.Create(); if (ant == null) { return; } Context.Get.Ants.Add(ant); Caption.Title("Available Hives"); ListView.Print(await Context.Get.Hives.ToListAsync()); var hiveID = Ask.Value("Enter Hive ID"); var selectedHive = Context.Get.Hives.Find(hiveID); if (selectedHive != null) { selectedHive.Ants.Add(ant); } Context.Save(); }