Beispiel #1
0
        public static void RemoveUser()
        {
            int id = ServantClass.CheckId("Enter user ID to remove user: "******"User: {user.ShowUserInfo()}");

                    if (UserLogic.Remove(id))
                    {
                        Console.WriteLine("User successfully removed.");
                    }
                    else
                    {
                        Console.WriteLine("Cannot to remove user.");
                    }
                }
                else
                {
                    Console.WriteLine("There are no users with this ID.");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Cannot to remove user.");
                Console.WriteLine(e.Message);

                throw;
            }
        }
Beispiel #2
0
        public static void GetUserById()
        {
            int id = ServantClass.CheckId("Enter ID number to get user by ID: ");

            try
            {
                User user = UserLogic.GetById(id);

                if (user != null)
                {
                    Console.WriteLine(user.ShowUserInfo());
                }
                else
                {
                    Console.WriteLine("There are no users with this ID.");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Cannot to get user by ID");
                Console.WriteLine(e.Message);

                throw;
            }
        }
Beispiel #3
0
        public static void RemoveAward()
        {
            int id = ServantClass.CheckId("Enter award ID to remove award: ");

            if (AwardLogic.Remove(id))
            {
                Console.WriteLine("Award successfully removed.");
            }
            else
            {
                Console.WriteLine("Cannot to remove award.");
            }
        }
Beispiel #4
0
        public static void TakeFromUser()
        {
            int userId  = ServantClass.CheckId(UserIdMessage);
            int awardId = ServantClass.CheckId(AwardIdMessage);

            if (AwardLogic.TakeAward(userId, awardId))
            {
                Console.WriteLine("Award successfully taken.");
            }
            else
            {
                Console.WriteLine("Cannot to take award.");
            }
        }
Beispiel #5
0
        public static void GiveToUser()
        {
            int userId  = ServantClass.CheckId(UserIdMessage);
            int awardId = ServantClass.CheckId(AwardIdMessage);

            if (AwardLogic.GiveAward(userId, awardId))
            {
                Console.WriteLine("Award successfully given.");
            }
            else
            {
                Console.WriteLine("Cannot to give award.");
            }
        }
Beispiel #6
0
        public static void UpdateUser()
        {
            int id = ServantClass.CheckId("Enter user ID to update user data: ");

            try
            {
                User user = UserLogic.GetById(id);

                if (user != null)
                {
                    Console.Write("User: "******"There are no users with this ID.");
                    return;
                }

                Console.WriteLine("Enter new user details:");

                string   firstName = ServantClass.AddUserName(FirstNameMessage);
                string   lastName  = ServantClass.AddUserName(LastNameMessage);
                DateTime birthDate = ServantClass.AddUserBirthDate(BirthDateMessage);

                UserLogic.Update(id, new User(firstName, lastName, birthDate));

                Console.WriteLine("User successfully updated.");
            }
            catch (Exception e)
            {
                Console.WriteLine("Cannot to update user.");
                Console.WriteLine(e.Message);

                throw;
            }
        }