//TestMethod
        public void AddMeasurement_WithANewMeasurement_GetAllMeasurementReturnsTheMeasurement()
        {
            using (IDal dal = new Dal())

            {

                dal.AddMeasurement(62, 70, 75, 100.5, 58.5, 38, 81, 25);

                List<Measurement> measures = dal.GetAllMeasurements();

                Assert.IsNotNull(measures);

                Assert.AreEqual(1, measures.Count);

                Assert.AreEqual("La bonne fourchette", measures[0].Weight);
                Assert.AreEqual("La bonne fourchette", measures[0].Waist);
                Assert.AreEqual("La bonne fourchette", measures[0].Tummy);
                Assert.AreEqual("La bonne fourchette", measures[0].Hips);
                Assert.AreEqual("La bonne fourchette", measures[0].Thigh);
                Assert.AreEqual("La bonne fourchette", measures[0].Calf);
                Assert.AreEqual("La bonne fourchette", measures[0].Breast);
                Assert.AreEqual("01 02 03 04 05", measures[0].Biceps);

            }
        }
        public void AddMeasurement_WithANewMeasurement_GetAllMeasurementReturnsTheMeasurement()
        {
            using (IDal dal = new Dal())
            {
                DateTime localDate = DateTime.Now;
                dal.AddMeasurement(localDate, 62, 70, 75, 100.5, 58.5, 38, 81, 25);
                List<Measurement> measures = dal.GetAllMeasurements();

                Assert.IsNotNull(measures);
                Assert.AreEqual(1, measures.Count);
                Assert.AreEqual(62, measures[0].Weight);
                Assert.AreEqual(70, measures[0].Waist);
                Assert.AreEqual(75, measures[0].Tummy);
                Assert.AreEqual(100.5, measures[0].Hips);
                Assert.AreEqual(58.5, measures[0].Thigh);
                Assert.AreEqual(38, measures[0].Calf);
                Assert.AreEqual(81, measures[0].Breast);
                Assert.AreEqual(25, measures[0].Biceps);

            }
        }
        public string AddMeasurement()
        {
            string date = Request.QueryString["measurementsDate"];
            string weight = Request.QueryString["weight"];
            string waist = Request.QueryString["waist"];
            string tummy = Request.QueryString["tummy"];
            string hips = Request.QueryString["hips"];
            string thigh = Request.QueryString["thigh"];
            string calf = Request.QueryString["calf"];
            string breast = Request.QueryString["breast"];
            string biceps = Request.QueryString["biceps"];

            double wgt;
            double newWeight;
            double wst;
            double newWaist;
            double t;
            double newTummy;
            double h;
            double newHips;
            double tgh;
            double newThigh;
            double c;
            double newCalf;
            double br;
            double newBreast;
            double bi;
            double newBiceps;

            if (double.TryParse(weight, out wgt))
                newWeight = wgt;
            else
                newWeight = 0;

            if (double.TryParse(waist, out wst))
                newWaist = wst;
            else
                newWaist = 0;

            if (double.TryParse(tummy, out t))
                newTummy = t;
            else
                newTummy = 0;

            if (double.TryParse(tummy, out h))
                newHips = h;
            else
                newHips = 0;

            if (double.TryParse(tummy, out tgh))
                newThigh = tgh;
            else
                newThigh = 0;

            if (double.TryParse(tummy, out c))
                newCalf = c;
            else
                newCalf = 0;

            if (double.TryParse(tummy, out br))
                newBreast = br;
            else
                newBreast = 0;

            if (double.TryParse(tummy, out bi))
                newBiceps = bi;
            else
                newBiceps = 0;

            DateTime convertedDate;
            try
            {
                convertedDate = Convert.ToDateTime(date);
                Console.WriteLine("'{0}' converts to {1} {2} time.",
                                  date, convertedDate,
                                  convertedDate.Kind.ToString());
                if (newWeight != 0 && newWaist != 0 && newBiceps != 0 && newBreast != 0 && newCalf != 0 && newHips != 0 && newThigh != 0 & newTummy != 0)
                {
                    using (IDal dal = new Dal())
                    {
                        dal.AddMeasurement(convertedDate, newWeight, newWaist, newTummy, newHips, newThigh, newCalf, newBreast, newBiceps);
                    }
                }
            }
            catch (FormatException)
            {
                Console.WriteLine("'{0}' is not in the proper format.", date);
            }

            //Console.WriteLine("Added Measurments: {0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}",
            //    date,
            //weight,
            //waist,
            //tummy,
            //hips,
            //thigh,
            //calf,
            //breast,
            //biceps);

            return "Done!";
        }
        //used to return measurements into the card on Home page
        public ActionResult ListMeasurementsHomePage()
        {
            List<Measurement> measurement = new List<Measurement>();
            using (IDal dal = new Dal())
            {
                measurement = dal.GetAllMeasurements();

            }
            ViewData["Measurements"] = measurement;
            return View("Index");
        }
        public ActionResult AddMeasurement(Measurement model)
        {
            DateTime date = model.MeasurementsDate;
            double weight = model.Weight;
            double waist = model.Waist;
            double tummy = model.Tummy;
            double hips = model.Hips;
            double thigh = model.Thigh;
            double calf = model.Calf;
            double breast = model.Breast;
            double biceps = model.Biceps;

               /* double wgt;
            double newWeight;
            double wst;
            double newWaist;
            double t;
            double newTummy;
            double h;
            double newHips;
            double tgh;
            double newThigh;
            double c;
            double newCalf;
            double br;
            double newBreast;
            double bi;
            double newBiceps;

            //if (double.TryParse(weight, out wgt))
              //  newWeight = wgt;
               // else
                newWeight = 0;

            if (double.TryParse(waist, out wst))
                newWaist = wst;
            else
                newWaist = 0;

            if (double.TryParse(tummy, out t))
                newTummy = t;
            else
                newTummy = 0;

            if (double.TryParse(tummy, out h))
                newHips = h;
            else
                newHips = 0;

            if (double.TryParse(tummy, out tgh))
                newThigh = tgh;
            else
                newThigh = 0;

            if (double.TryParse(tummy, out c))
                newCalf = c;
            else
                newCalf = 0;

            if (double.TryParse(tummy, out br))
                newBreast = br;
            else
                newBreast = 0;

            if (double.TryParse(tummy, out bi))
                newBiceps = bi;
            else
                newBiceps = 0;

            DateTime convertedDate;
            try
            {
                convertedDate = Convert.ToDateTime(date);
                Console.WriteLine("'{0}' converts to {1} {2} time.",
                                  date, convertedDate,
                                  convertedDate.Kind.ToString());
                if (newWeight != 0 && newWaist != 0 && newBiceps != 0 && newBreast != 0 && newCalf != 0 && newHips != 0 && newThigh != 0 & newTummy != 0)
                {*/
                    using (IDal dal = new Dal())
                    {
                        dal.AddMeasurement(date, weight, waist, tummy, hips, thigh, calf, breast, biceps);
                    }
               /*}
            }
            catch (FormatException)
            {
                Console.WriteLine("'{0}' is not in the proper format.", date);
            }*/

            //Console.WriteLine("Added Measurments: {0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}",
            //    date,
            //weight,
            //waist,
            //tummy,
            //hips,
            //thigh,
            //calf,
            //breast,
            //biceps);

            return View("Measurements");
        }
        // GET: Measurements
        public ActionResult Index()
        {
            List<Measurement> measurement = new List<Measurement>();
            using (IDal dal = new Dal())
            {
                measurement = dal.GetAllMeasurements();

            }
            return View("Measurements", measurement);
        }