//
        // GET: /Account/Edit
        public ActionResult Edit()
        {
            String userEmail = User.Identity.Name;

            DBAccessor dba = new DBAccessor();
            Person user = dba.GetPersonInformation(userEmail);
            EditModel model = new EditModel();

            if (user != null) {
                model.FirstName = user.firstName;
                model.LastName = user.lastName;
                model.Email = user.email;
                model.Birthday = user.birthday;
                model.Height = Convert.ToInt16(user.height);
                model.Weight = Convert.ToInt16(user.weight);
                model.ImageURL = user.imageURL;
            }
            else {
                return RedirectToAction("Index", "Home");
            }

            return View(model);
        }
        public ActionResult Edit(EditModel model)
        {
            if (ModelState.IsValid) {
                // Update the user in the MySQL DB
                String oldEmail = User.Identity.Name;
                DBAccessor dba = new DBAccessor();
                LogonResponse result = dba.CheckLoginCredentials(oldEmail, model.Password);

                if (result.success == (int)LogonResults.SUCCESS) {

                    Person updateUser = new Person(model.FirstName, model.LastName, model.Email, model.ImageURL, "", model.Birthday, model.Height, model.Weight);
                    dba.UpdateUserInformation(oldEmail, updateUser);

                    // Set the appropriate cookies
                    FormsAuthentication.SetAuthCookie(model.Email, false /* createPersistentCookie */);
                    HttpCookie cookie = new HttpCookie(AppConstants.COOKIE_NAME, model.FirstName + " " + model.LastName);
                    cookie.Expires = DateTime.Now.AddDays(1000);
                    this.ControllerContext.HttpContext.Response.Cookies.Add(cookie);
                }
                else {
                    ModelState.AddModelError("", result.errorMessage);
                }
            }

            return View(model);
        }