protected void ButtonAgeInDays_Click(object sender, EventArgs e)
 {
     var ageInDaysClient=new CalculateAgeClient();
     DateTime birthday;
     DateTime.TryParse(TextBoxAgeInDays.Text, out birthday);
     LabelPrintBirthdayInDays.Text=ageInDaysClient.CalculateAge(birthday);
 }
Example #2
0
        static void Main(string[] args)
        {
            var host = new CalculateAgeClient();
            var x = DateTime.Now;
            Console.Write("Enter your age (YYYY/MM/DD): ");
            var age = Console.ReadLine();
            var parsedAge = DateTime.TryParse(age, out x) ? DateTime.Parse(age) : x;

            Console.WriteLine($"Du är {host.CalculateAge(parsedAge)} år gammal");
            Console.ReadKey();
        }
Example #3
0
        static void Main(string[] args)
        {
            var host = new CalculateAgeClient();
            var x    = DateTime.Now;

            Console.Write("Enter your age (YYYY/MM/DD): ");
            var age       = Console.ReadLine();
            var parsedAge = DateTime.TryParse(age, out x) ? DateTime.Parse(age) : x;

            Console.WriteLine($"Du är {host.CalculateAge(parsedAge)} år gammal");
            Console.ReadKey();
        }
Example #4
0
        static void Main(string[] args)
        {
            DateTime birthday;
            var ageClient = new CalculateAgeClient();
            Console.WriteLine("Calculate how many days old you are");
            Console.WriteLine("--------------------------------------------------------");
            Console.WriteLine("Please enter your birthday, in the format YYYY,MM,DD: ");
            DateTime.TryParse(Console.ReadLine(), out birthday);
            Console.WriteLine(ageClient.CalculateAge(birthday));
            Console.WriteLine("Press enter to continue");
            Console.ReadLine();

            var bmiClient = new CalculateBmiClient();
            Console.WriteLine("Calculate your BMI");
            Console.WriteLine("---------------------------------------------------------");
            Console.WriteLine("Please enter your weight: ");
            var bmiWeight=0.0;
            double.TryParse(Console.ReadLine(), out bmiWeight);
            Console.WriteLine("Please enter your height: ");
            var bmiHeight=0.0; 
            double.TryParse(Console.ReadLine(), out bmiHeight);
            Console.WriteLine(bmiClient.CalculateBmi(bmiWeight, bmiHeight));
            Console.WriteLine("Press enter to continue");
            Console.ReadLine();

            var evenBirthdayClient = new CalculateEvenBirthdayClient();
            Console.WriteLine("Calculate when your next even 1000-day birthday is");
            Console.WriteLine("---------------------------------------------------------");
            Console.WriteLine("Please enter your birthday: ");
            DateTime.TryParse(Console.ReadLine(), out birthday);
            Console.WriteLine(evenBirthdayClient.CalculateEvenBirthday(birthday));
            Console.WriteLine("Press enter to continue");
            Console.ReadLine();

            var calorieClient = new CalculateCaloriesClient();
            Console.WriteLine("Calculate how many calories you have burned");
            Console.WriteLine("---------------------------------------------------------");
            Console.WriteLine("Please enter one of the following workout types: ");
            Console.WriteLine("1. Wrestling");
            Console.WriteLine("2. Walking");
            Console.WriteLine("3. Yoga");
            Console.WriteLine("4. Weight lifting");
            var workoutType = Console.ReadLine();
            Console.WriteLine("Please enter duration of exercise in minutes: ");
            var duration = 0; 
            int.TryParse(Console.ReadLine(), out duration);
            Console.WriteLine("Please enter your weight: ");
            var weight = 0.0;
            double.TryParse(Console.ReadLine(), out weight);
            Console.WriteLine(calorieClient.CalculateCalories(workoutType, duration, weight) + " calories");
            Console.WriteLine("Press enter to continue");
            Console.ReadLine();
        }
Example #5
0
 static void Main(string[] args)
 {
     CalculateAgeClient host = new CalculateAgeClient();
     System.Console.WriteLine("Enter your year: ");
     var year = System.Console.ReadLine();
     System.Console.WriteLine("Enter your month: ");
     var month = System.Console.ReadLine();
     System.Console.WriteLine("Enter your day: ");
     var day = System.Console.ReadLine();
     var date = new DateTime(int.Parse(year), int.Parse(month), int.Parse(day));
     System.Console.WriteLine(host.CalculateAge(date));
 }
Example #6
0
        static void Main(string[] args)
        {
            CalculateAgeClient host = new CalculateAgeClient();

            System.Console.WriteLine("Enter your year: ");
            var year = System.Console.ReadLine();

            System.Console.WriteLine("Enter your month: ");
            var month = System.Console.ReadLine();

            System.Console.WriteLine("Enter your day: ");
            var day  = System.Console.ReadLine();
            var date = new DateTime(int.Parse(year), int.Parse(month), int.Parse(day));

            System.Console.WriteLine(host.CalculateAge(date));
        }
Example #7
0
        private void btnMessage_Click(object sender, EventArgs e)
        {
            try
            {
                if (host.State == System.ServiceModel.CommunicationState.Faulted)
                {
                    host = new CalculateAgeClient();
                }

                var dateOfBirth = new DateTime(int.Parse(txtBoxYear.Text), int.Parse(txtBoxMonth.Text), int.Parse(txtBoxDay.Text));
                lblMessage.Text = host.CalculateAge(dateOfBirth);
            }
            catch (CommunicationException ex)
            {
                lblMessage.Text = $"Error please try again. {ex.Message}";
                throw;
            }
        }