Exemplo n.º 1
0
 static void Main(string[] args)
 {
     DateTime date = DateTime.Parse("2003-11-4");
     ImpreciseServiceClient client = new ImpreciseServiceClient();
     int years = client.GetAge(date);
     Console.WriteLine("The guy born in {0:yyyy-MM-dd} is {1} years old", date, years);
     DateTime date2 = DateTime.Parse("2009-01-02");
     years = client.AgeDifference(date, date2);
     Console.WriteLine("The difference between {0:yyyy-MM-dd} and {1:yyyy-MM-dd} is {2} years", date, date2, years);
     Console.ReadLine();
 }
Exemplo n.º 2
0
        public ActionResult Calculate(Models.ImpreciseDateCalc calc)
        {
            DateTime date = DateTime.Parse(calc.DOB);
            DateTime fromDate = DateTime.Parse(calc.DateFrom);
            DateTime toDate = DateTime.Parse(calc.DateTo);

            using (ImpreciseServiceClient client = new ImpreciseServiceClient())
            {
                calc.Age = client.GetAge(date);
                calc.Years = client.AgeDifference(fromDate, toDate);
            }

            //PreciseServiceClient preciseClient = new PreciseServiceClient();
            //calc.Age = preciseClient.GetAge(date);
            //calc.PreciseYears = preciseClient.AgeDifference(fromDate, toDate);

            return RedirectToAction("Index", calc);
        }