コード例 #1
0
        private static void ShowAwardUsers()
        {
            Console.WriteLine("Enter award id");
            string awardstring = Console.ReadLine();
            int    awardid;

            while (!int.TryParse(awardstring, out awardid))
            {
                Console.WriteLine("Enter a valid integer");
                awardstring = Console.ReadLine();
            }
            try
            {
                var users = awardLogic.Users(awardid);

                var award = awardLogic.Get(awardid);

                if (users.Count > 0)
                {
                    Console.WriteLine($"Award {award.Name} has been granted to these users:");
                    foreach (var user in users)
                    {
                        Console.WriteLine($"{user.Username}");
                    }
                }
                else
                {
                    Console.WriteLine($"Award {award.Name} has not been granted to any user");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }