Exemplo n.º 1
0
        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);
        }