public ActionResult Edit(User user) { if (ModelState.IsValid) { var folder = "~/Content/Golo"; var pic = string.Empty; if (user.UserPhotoFile != null) { var response = FilHelper.UploadPhoto(user.UserPhotoFile, folder, string.Format("{0}.jpg", user.UserId)); if (response) { pic = string.Format("{0}/{1}.jpg", folder, user.UserId); user.UserPhoto = pic; } } var db2 = new DBPrintumContext(); var currentUser = db2.Users.Find(user.UserId); if (currentUser.UserName != user.UserName) { UsersHelper.UpdateUserName(currentUser.UserName, user.UserName); } db2.Dispose(); db.Entry(user).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CityId = new SelectList(ComboHelper.getCities(), "CityId", "CitiesName", user.CityId); ViewBag.CompanyId = new SelectList(ComboHelper.getCompanies(), "CompanyId", "CompanyName", user.CompanyId); ViewBag.DepartmentId = new SelectList(ComboHelper.getDepartment(), "DepartmentId", "DepartmentName", user.DepartmentId); return(View(user)); }
protected override void Dispose(bool disposing) { if (disposing) { db.Dispose(); } base.Dispose(disposing); }
public void Dispose() { db.Dispose(); }
public void Dispose() { userContext.Dispose(); db.Dispose(); }