コード例 #1
0
        //Creating new Developer
        private void CreateNewDeveloper()
        {
            Console.Clear();
            Developer newDeveloper = new Developer();

            //EmployeeId
            Console.WriteLine("Enter a unique ID for the Employee:");
            newDeveloper.EmployeeId = Console.ReadLine();

            //EmployeeName
            Console.WriteLine("Enter the name for the Employee:");
            newDeveloper.EmployeeName = Console.ReadLine();

            //EmployeeStartDate
            Console.WriteLine("Enter the Employee Start Date (MM-DD-YYYY): ");
            DateTime userDateTime;
            bool     FoundDate;

            if (DateTime.TryParse(Console.ReadLine(), out userDateTime))
            {
                newDeveloper.StartDate = userDateTime;
                FoundDate = true;
            }
            else
            {
                Console.WriteLine("You have entered an incorrect value.");
                FoundDate = false;
            }

            //Pluralsight Licence
            Console.WriteLine("Does Employee have Pluralsight Licence (Y/N):");
            string Pluralsight = Console.ReadLine().ToUpper();

            if (Pluralsight == "Y")
            {
                newDeveloper.PluralsightLicence = true;
            }
            else
            {
                newDeveloper.PluralsightLicence = false;
            }

            //IsActive
            Console.WriteLine("Is the Employee still active (Y/N)?:");
            string Active = Console.ReadLine().ToUpper();

            if (Active == "Y")
            {
                newDeveloper.ActiveEmplyoee = true;
            }
            else
            {
                newDeveloper.ActiveEmplyoee = false;
            }


            //show everything on content list
            List <DevTeam> listofTeams = _developerTeamRepo.GetDeveloperTeamLists();

            Console.WriteLine("List of Teams:\n");
            foreach (DevTeam devTeam in listofTeams)
            {
                Console.WriteLine($"Team ID: {devTeam.TeamId}  , Desc: {devTeam.TeamDescription}\n");
            }
            string devteamid = Console.ReadLine();
            //bool isConvertible = false;
            //int parsedInt = 0;
            bool FoundTeam = false;

            if (int.TryParse(devteamid, out int parsedInt))
            {
                //Find Team in List
                DevTeam devTeamFind = _developerTeamRepo.GetDevTeamById(parsedInt);

                if (devTeamFind != null)
                {
                    newDeveloper.DevTeamId = devTeamFind.TeamId;
                    FoundTeam = true;
                }
                else
                {
                    Console.WriteLine($"Team: {devteamid} not found.");
                    FoundTeam = false;
                }
            }

            else
            {
                Console.WriteLine($"Team: {devteamid} not found.");
            }

            if (FoundDate == true && FoundTeam == true)
            {
                _developerDirectory.AddDeveloperToLists(newDeveloper);
            }
            else
            {
                Console.WriteLine("Developer Not Created - Required Information not entered properly.  Try Again!!");
            }
        }