public void UpdateCoach()
        {
            Console.WriteLine("Enter Coach id:");
            string coachId = Console.ReadLine();
            int    tryint;

            while (!int.TryParse(coachId, out tryint))
            {
                Console.WriteLine("Incorrect id! Try again ");
                coachId = Console.ReadLine();
            }

            Console.Write("Enter Coach name:");
            string newName = Console.ReadLine();

            while (!IsAllAlphabetic(newName))
            {
                Console.WriteLine("Incorrect Name! Try again");
                newName = Console.ReadLine();
            }

            Console.Write("Enter Coach surname:");
            string newSurname = Console.ReadLine();

            while (!IsAllAlphabetic(newSurname))
            {
                Console.WriteLine("Incorrect Surname! Try again");
                newSurname = Console.ReadLine();
            }

            Console.Write("Enter Coach work experience:");
            string newWorkExperience = Console.ReadLine();

            while ((!int.TryParse(newWorkExperience, out tryint)) || (!WorkExperienceValidationAttribute.IsValidCoachExperience(Convert.ToInt32(newWorkExperience))))
            {
                Console.WriteLine("Incorrect Work Experience! Try again ");
                newWorkExperience = Console.ReadLine();
            }

            try
            {
                Coach coach = new Coach {
                    FirstName = newName, LastName = newSurname, WorkExperience = Convert.ToInt32(newWorkExperience)
                };
                using (swimmingContext swimdb = new swimmingContext())
                {
                    ICoachManager <Coach> coachManager = new CoachRepository(swimdb);
                    coachManager.Update(Convert.ToInt32(coachId), coach);
                    Console.WriteLine("Coach is updated");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Exemple #2
0
        public void AddCoach()
        {
            Console.Write("Enter Coach name:");
            string name = Console.ReadLine();

            while (!IsAllAlphabetic(name))
            {
                Console.WriteLine("Incorrect Name! Try again");
                name = Console.ReadLine();
            }

            Console.Write("Enter Coach surname:");
            string surname = Console.ReadLine();

            while (!IsAllAlphabetic(surname))
            {
                Console.WriteLine("Incorrect Surname! Try again");
                surname = Console.ReadLine();
            }

            Console.Write("Enter Coach work experience:");
            string workExperience = Console.ReadLine();
            int    tryint;

            while ((!int.TryParse(workExperience, out tryint)) || (!WorkExperienceValidationAttribute.IsValidCoachExperience(Convert.ToInt32(workExperience))))
            {
                Console.WriteLine("Incorrect Work Experience! Try again ");
                workExperience = Console.ReadLine();
            }

            try
            {
                Coach coach = new Coach {
                    FirstName = name, LastName = surname, WorkExperience = Convert.ToInt32(workExperience)
                };
                _coachManager.Add(coach);
                Console.WriteLine("Coach is added");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Exemple #3
0
        public void Attribute_WorkExperienceValidation_IsValid(int value)
        {
            bool result = WorkExperienceValidationAttribute.IsValidCoachExperience(value);

            Assert.AreEqual(result, false);
        }