public ActionResult EditUserConfirmed(User user) { db.Entry(user).State = EntityState.Modified; db.SaveChanges(); TempData["alertMessage"] = "Аккаунт успешно изменен."; if (user.Login == User.Identity.Name) { return(RedirectToAction("Logoff", "Account")); } return(RedirectToAction("AccountsSettings")); }
public ActionResult Edit([Bind(Include = "Id,PersonIdFrom,PersonIdTo,TariffId,Description,Weight,Length,Width,Height,NumberOfPackages,Cost,DeclaredValue")] Package package) { if (ModelState.IsValid) { db.Entry(package).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.PersonIdFrom = new SelectList(db.Persons, "Id", "Name", package.PersonIdFrom); ViewBag.PersonIdTo = new SelectList(db.Persons, "Id", "Name", package.PersonIdTo); ViewBag.TariffId = new SelectList(db.Tariffs, "Id", "Name", package.TariffId); return(View(package)); }
public ActionResult Edit([Bind(Include = "Id,PersonIdFrom,PersonIdTo,TariffId,Description,Weight,Length,Width,Height,NumberOfPackages,Cost,DeclaredValue")] Package package) { if (package.Weight == null || package.Length == null || package.Width == null || package.Height == null) { ModelState.AddModelError("", "Необходимо заполнить поля о весе и размерах груза"); } if (ModelState.IsValid) { if (package.TariffId != null) { package.Cost = Helper.EvaluateCost((int)package.TariffId, (double)package.Weight, (double)package.Height, (double)package.Length, (double)package.Width); // package.Tariff = db.Tariffs.Find(package.TariffId); } db.Entry(package).State = EntityState.Modified; db.SaveChanges(); TempData["alertMessage"] = "Данные об отправлении изменены."; return(RedirectToAction("Details", new { id = package.Id })); } Package refreshPackage = db.Packages.Find(package.Id); InitSelectLists(refreshPackage); return(View(refreshPackage)); }
public ActionResult UpdatePassword(OldNewPasswordModel passwords) // oldPass, newPass { if (ModelState.IsValid) { User user = db.Users.Where(a => a.Login == User.Identity.Name).First(); if (user.Password == passwords.OldPassword) { user.Password = passwords.NewPassword; db.Entry(user).State = EntityState.Modified; db.SaveChanges(); TempData["alertMessage"] = "Пароль учетной записи успешно изменен."; return(RedirectToAction("Index", "UserSettings")); } else { ModelState.AddModelError("", "Текущий пароль введен неверно"); } } ViewBag.AccountReferences = db.AccountReferences.Where(a => a.User.Login == User.Identity.Name); return(View("Index")); }