Esempio n. 1
0
        private static void ShowUsersWithAwards()
        {
            var users = _userLogic.GetAll();

            if (users.Count() == 0)
            {
                Console.WriteLine("No users in DB.");
                return;
            }

            foreach (var user in users)
            {
                Console.WriteLine(user);
                var awards = _awardLogic.GetAwardsByUserId(user.Id);
                Console.Write("Awards: ");
                if (awards.Count() != 0)
                {
                    foreach (var award in awards)
                    {
                        Console.Write($"{award.Title}; ");
                    }
                    Console.WriteLine();
                }
                else
                {
                    Console.WriteLine("No awards.");
                }
            }
        }
Esempio n. 2
0
        public static MvcHtmlString ShowUserAndAwards(User user)
        {
            _sb.Clear();
            _sb.Append($"{user.ToString()}<br>");
            var awards = _awardLogic.GetAwardsByUserId(user.Id);

            if (awards.Any())
            {
                _sb.Append("Awards:");
                foreach (var award in awards)
                {
                    _sb.Append($" {award.Title},");
                }
                _sb.Remove(_sb.Length - 1, 1);
                _sb.Append(".");
            }
            else
            {
                _sb.Append("No Awards.");
            }
            return(MvcHtmlString.Create(_sb.ToString()));
        }
Esempio n. 3
0
        private static void ListAllUsers(IUserLogic userLogic, IAwardLogic awardLogic)
        {
            try
            {
                foreach (var user in userLogic.GetAllUsers())
                {
                    string strId = $"{user.Id}.";
                    string strName = $" Name: \"{user.Name}\"";
                    string strDate = $" BirthDay: \"{user.BirthDay.ToShortDateString()}\"";
                    string strAge = $" Age: \"{userLogic.GetAge(user.BirthDay)}\"";

                    Console.WriteLine(strId + strName + strDate + strAge);

                    foreach (var award in awardLogic.GetAwardsByUserId(user.Id))
                    {
                        Console.WriteLine($"\tHas award: \"{award.Title}\"");
                    }

                    Console.WriteLine();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            Console.WriteLine();
        }