public ActionResult Edit(AccountEdit acc) { acc._acc = Authentication.CurrentAccount; if (ModelState.IsValid) { if (acc.password != acc._acc.password) { ModelState.AddModelError("password", GlobalRes.PasswordError); return View("Edit", acc); } if (acc.password != null && acc.newPassword != "Password") DataBase.Account.editPassword(acc); if (acc.email != null) { if (DataBase.Account.emailUpdate(acc)) { return RedirectToAction("EmailSubmit", new { email = acc.email }); } else { ModelState.Add("updated", new ModelState { Value = new ValueProviderResult("success", GlobalRes.ErrorBadRequestBody, null) }); } } else { return View("PasswordChanged"); } } return View("Edit", acc); }
public static bool emailUpdate(AccountEdit account) { try { emailUpdate NewUpdate = new emailUpdate() { owner = account.id, confirmation = CreateMD5Hash("update" + account.id.ToString() + Time.UNIXNow()), date = Time.UNIXNow(), email = account.email }; context.emailUpdate.InsertOnSubmit(NewUpdate); if (Save()) { Mailer.EmailSubmit(NewUpdate.email, NewUpdate.confirmation); return true; } return false; } catch { return false; } }
public ActionResult Edit() { AccountEdit acc = new AccountEdit(Authentication.CurrentAccount); return View("Edit", acc); }
/* public static bool edit(int aid, string password, string email) { try { var acc = context.accounts.FirstOrDefault(ac => ac.ID == aid); if (context.accounts.FirstOrDefault(ac => ac.email == email) == null) { if (password != "") acc.password = password; if (email != "") acc.email = email; } Save(); return false; } catch { return false; } } */ public static bool editPassword(AccountEdit account) { try { var acc = context.accounts.FirstOrDefault(ac => ac.ID == account.id); if (acc.email != null) acc.email = account.email; acc.password = account.password; return Save(); } catch { return false; } }