public ActionResult DeleteConfirmed(int id)
        {
            WeightLoss weightLoss = db.WeightLosses.Find(id);

            db.WeightLosses.Remove(weightLoss);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "ID,UserID,caloriesBurnedSoFar,caloriesBurnedThisWorkout,expectedCaloriesBurned,caloriesEaten,amtOfWeightLoss,today,BMI,BMR")] WeightLoss weightLoss)
 {
     if (ModelState.IsValid)
     {
         db.Entry(weightLoss).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(weightLoss));
 }
        public ActionResult Create([Bind(Include = "ID,UserID,caloriesBurnedSoFar,caloriesBurnedThisWorkout,expectedCaloriesBurned,caloriesEaten,amtOfWeightLoss,today,BMI,BMR,howActiveMultiplier,activityMultiplier")] WeightLoss weightLoss)
        {
            weightLoss.today = DateTime.Now.DayOfYear;
            if (ModelState.IsValid)
            {
                weightLoss.UserID = User.Identity.GetUserId();

                var alreadyEnteredInfo = db.WeightLosses.Where(u => u.UserID == weightLoss.UserID).FirstOrDefault();

                if (alreadyEnteredInfo != null)
                {
                    db.WeightLosses.RemoveRange(db.WeightLosses.Where(s => s.UserID == weightLoss.UserID));
                    db.SaveChanges();
                }

                weightLoss.UserID = User.Identity.GetUserId();
                var userid = User.Identity.GetUserId();//left off here last night danielyang
                var height = db.UserInformations.Where(u => u.UserID == userid).Select(h => h.height).FirstOrDefault();
                var weight = db.UserInformations.Where(u => u.UserID == userid).Select(w => w.weight).FirstOrDefault();
                var age    = db.UserInformations.Where(u => u.UserID == userid).Select(a => a.age).FirstOrDefault();

                if (weightLoss.howActiveMultiplier == "VA")
                {
                    weightLoss.activityMultiplier = 1.725;
                }
                else if (weightLoss.howActiveMultiplier == "SA")
                {
                    weightLoss.activityMultiplier = 1.55;
                }
                else if (weightLoss.howActiveMultiplier == "NA")
                {
                    weightLoss.activityMultiplier = 1.2;
                }

                if (db.UserInformations.Where(u => u.UserID == userid).Select(s => s.sex).FirstOrDefault() == "Male")
                {
                    weightLoss.BMR = Math.Round((4.53592 * weight) + (15.875 * height) - (5 * age) + 5);
                    weightLoss.BMI = Math.Round((703 * weight / Math.Pow(height, 2)), 1);
                }
                else if (db.UserInformations.Where(u => u.UserID == userid).Select(s => s.sex).FirstOrDefault() == "Female")
                {
                    weightLoss.BMR = Math.Round((4.53592 * weight) + (15.875 * height) - (5 * age) - 161);
                    weightLoss.BMI = Math.Round((703 * weight / Math.Pow(height, 2)), 1);
                }


                db.WeightLosses.Add(weightLoss);
                db.SaveChanges();
                return(RedirectToAction("Index", "Home"));
            }

            return(View(weightLoss));
        }
        // GET: WeightLosses/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            WeightLoss weightLoss = db.WeightLosses.Find(id);

            if (weightLoss == null)
            {
                return(HttpNotFound());
            }
            return(View(weightLoss));
        }