Example #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;
            }
        }
Example #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;
            }
        }
Example #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.");
            }
        }
Example #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.");
            }
        }
Example #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.");
            }
        }
Example #6
0
        public static void AddAward()
        {
            string awardName = ServantClass.AddAwardTitle("Enter Award title: ");

            try
            {
                AwardLogic.Add(new Award(awardName));

                Console.WriteLine("Award successfully added.");
            }
            catch (Exception e)
            {
                Console.WriteLine("Cannot to add award.");
                Console.WriteLine(e.Message);

                throw;
            }
        }
Example #7
0
        public static void AddUser()
        {
            try
            {
                string   firstName = ServantClass.AddUserName(FirstNameMessage);
                string   lasttName = ServantClass.AddUserName(LastNameMessage);
                DateTime birthDate = ServantClass.AddUserBirthDate(BirthDateMessage);

                UserLogic.Add(new User(firstName, lasttName, birthDate));

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

                throw;
            }
        }
Example #8
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;
            }
        }