예제 #1
0
        public static bool Validate(Employee employee)
        {
            if (string.IsNullOrEmpty(employee.UserName))
            {
                Console.WriteLine("Invalid userName");
                StandardMessages.EndApp();
                return(false);
            }

            if (string.IsNullOrEmpty(employee.LastName))
            {
                Console.WriteLine("Invalid LastName");
                StandardMessages.EndApp();
                return(false);
            }

            return(true);
        }
예제 #2
0
        static void Main(string[] args)
        {
            // Without SRP
            //Console.WriteLine("Test Application");

            //Employee employee = new Employee();
            //Console.WriteLine("Enter userName");
            //employee.UserName = Console.ReadLine();
            //Console.WriteLine("Enter LastName");
            //employee.LastName = Console.ReadLine();
            //employee.Id = new Random().Next(1,1000);

            //if (string.IsNullOrEmpty(employee.UserName))
            //{
            //    Console.WriteLine("Invalid userName");
            //    Console.ReadLine();
            //    return;
            //}

            //if (string.IsNullOrEmpty(employee.LastName))
            //{
            //    Console.WriteLine("Invalid LastName");
            //    Console.ReadLine();
            //    return;
            //}


            //Console.WriteLine($"you details are {employee.LastName}{employee.UserName}");
            //Console.ReadLine();

            // After restructuring to use SRP
            StandardMessages.StartMessage();
            Employee emp        = GetEmployeeData.CaptureData();
            bool     isValidEmp = ValidateEmployee.Validate(emp);

            if (!isValidEmp)
            {
                StandardMessages.EndApp();
                return;
            }
            Login.Create(emp);

            StandardMessages.EndApp();
        }