Exemple #1
0
        static void Main(string[] args)
        {
            var allUsers = UserService.GetAllUsers();

            //foreach (var user in allUsers)
            //{
            //    Console.WriteLine(user.FirstName);
            //}
            try
            {
                // var userByID = UserService.GetUserById(4);
                var usersFriends = UserService.GetAllUsersFriends(null);
                foreach (var user in usersFriends)
                {
                    Console.WriteLine(user.FirstName);
                }
                // Console.WriteLine(userByID.FirstName);
            }
            catch (UserServiceException ex)
            {
                Console.WriteLine(ex.Message);
            }
            catch (Exception ex)
            {
                var logger = new UserExceptionsLogger();
                logger.LogException(ex);
                Console.WriteLine(ex.Message);
            }
            Console.WriteLine("I proceed to work");
            Console.ReadLine();
        }
        static void Main(string[] args)
        {
            var allUsers = UserService.GetAllUsers();

            try
            {
                var userByID = UserService.GetUserById(4);
                Console.WriteLine(userByID.FirstName);
                var usersFriends = UserService.GetAllUsersFriends(null);
                foreach (var user in usersFriends)
                {
                    Console.WriteLine(user.FirstName);
                }
            }
            catch (UserServiceException ex)
            {
                Console.WriteLine(ex.Message);
            }
            catch (Exception ex)
            {
                var logger = new UserExceptionsLogger();
                logger.LogException(ex);
                Console.WriteLine(ex.Message);
            }

            var allAdmins = AdminService.GetAllAdmins();

            try
            {
                var adminId = AdminService.GetAdminId("Ron");
                Console.WriteLine(adminId);
                var adminHelpers = AdminService.GetAllAdminHelpers(null);
                foreach (var admin in adminHelpers)
                {
                    Console.WriteLine(admin.FirstName);
                }
            }
            catch (AdminServiceException ex)
            {
                Console.WriteLine(ex.Message);
            }
            catch (Exception ex)
            {
                var logger = new UserExceptionsLogger();
                logger.LogException(ex);
                Console.WriteLine(ex.Message);
            }
            Console.ReadLine();
        }
Exemple #3
0
        static void Main(string[] args)
        {
            var allUsers = UserService.GetAllUsers();

            //foreach (var user in allUsers)
            //{
            //    Console.WriteLine(user.FirstName);
            //}
            try
            {
                // var userByID = UserService.GetUserById(4);
                var usersFriends = UserService.GetAllUsersFriends(null);
                foreach (var user in usersFriends)
                {
                    Console.WriteLine(user.FirstName);
                }
                // Console.WriteLine(userByID.FirstName);
            }
            catch (UserServiceException ex)
            {
                Console.WriteLine(ex.Message);
            }
            catch (Exception ex)
            {
                var logger = new UserExceptionsLogger();
                logger.LogException(ex);
                Console.WriteLine(ex.Message);
            }
            Console.WriteLine("I proceed to work");


            var allAdmins = AdminService.GetAdmins();

            // foreach (var admin in allAdmins)
            //{
            //   Console.WriteLine(admin.FirstName);
            //}

            try
            {
                //  var adminById = AdminService.GetAdmin(6);
                var adminFriends = AdminService.GetAllAdminFriends(null);

                foreach (var admin in adminFriends)
                {
                    Console.WriteLine(admin.FirstName);
                }
                // Console.WriteLine(adminById.FirstName); //Aca -  it will never happened
                //Console.WriteLine("Again i proceed  to work"); //it will never happened
            }

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


            catch (Exception ex)
            {
                var logger = new AdminExceptionLoggerr();
                logger.AdminLogExeption(ex);
                Console.WriteLine(ex.Message);             //Sequence contains no matching element
            }
            Console.WriteLine("Again i proceed  to work"); // if its there it will happen



            Console.ReadLine();
        }
Exemple #4
0
        static void Main(string[] args)
        {
            var allUser = UserService.GetAllUsers();


            try
            {
                //var userByID = UserService.GetUserByID(4);
                var usersFrineds = UserService.GetAllUsersFriends(null);
                foreach (var user in usersFrineds)
                {
                    Console.WriteLine(user.FirstName);
                }
                //Console.WriteLine(userByID.FirstName);
            }
            catch (UserServiceException ex)
            {
                Console.WriteLine(ex.Message);
            }
            catch (Exception ex)
            {
                var logger = new UserExceptionsLogger();
                logger.LogExeption(ex);
                Console.WriteLine(ex.Message);
            }
            Console.WriteLine("I procesed to work");

            Console.ForegroundColor = ConsoleColor.DarkGreen;
            var allAdmins = AdminService.GetAllAdmins();

            try
            {
                var AdminByID = AdminService.GetAdminByID(30);
                Console.WriteLine(AdminByID.FirstName);
                var AdminsFriends = AdminService.GetAllAdminsFriends(null);// for admin service exception
                //var miki = AdminService.GetAdminByID(10);

                //if (miki.FirstName.Length > 3)//for logger exception
                //{
                //    throw new Exception();
                //}
                //var AdminsFriends = AdminService.GetAllAdminsFriends(AdminByID);
                //AdminsFriends.ForEach(friend => Console.WriteLine(friend.FirstName));
            }
            catch (AdminServiceException ex)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine($" Admin Service exeption: {ex.Message} {ex.StackTrace}");
                Console.WriteLine($"Inner Exeption msg: {ex.InnerException.Message}");
            }

            catch (Exception ex)
            {
                var loggeradmin = new AdminExceptionsLogger();
                loggeradmin.AdminLogExeption(ex);
                Console.ForegroundColor = ConsoleColor.Blue;
                Console.WriteLine($"Logger exception :  {ex.Message}");
            }


            Console.ReadLine();
        }