public ActionResult Edit([Bind(Include = "ID,UserName,Password,CourtID,FullName,RoleID,CreationDate,LastLoginDateTime,OfficeNumber,OfficeFloorNumber,OfficeName,IsActive,IsInworkToday,MaxQueueCount,Email,Phone,Mobile,LastUpdateDate,SocialID,ExtensionNumber,ActiveDirectoryUserName,olduserid,SubRoleID")] User user) { if (ModelState.IsValid) { db.Entry(user).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(user)); }
public ActionResult Edit([Bind(Include = "ID,UserID,CorutOfficeID,RoleID,SupRoleID,UpdateAdminID,UpdateDate,isActive")] Users_Courts users_Courts) { if (ModelState.IsValid) { if (db.Users_Courts.Where(x => x.UserID == users_Courts.UserID && x.CorutOfficeID == users_Courts.CorutOfficeID && x.RoleID == users_Courts.RoleID).FirstOrDefault() == null) { users_Courts.UpdateAdminID = Convert.ToInt32(Session["UserID"]); users_Courts.UpdateDate = DateTime.Now; //users_Courts.CreateDate = DateTime.Now; if (users_Courts.RoleID.Equals(3)) { users_Courts.SupRoleID = 1; } db.Users_Courts.Attach(users_Courts); db.Entry(users_Courts).Property(x => x.UpdateAdminID).IsModified = true; db.Entry(users_Courts).Property(x => x.UpdateDate).IsModified = true; db.Entry(users_Courts).Property(x => x.CorutOfficeID).IsModified = true; db.Entry(users_Courts).Property(x => x.RoleID).IsModified = true; db.Entry(users_Courts).Property(x => x.SupRoleID).IsModified = true; db.Entry(users_Courts).Property(x => x.isActive).IsModified = true; //db.Entry(users_Courts.UpdateDate).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } else { ViewBag.Message = "الربط موجود سابقاً"; } } ViewBag.CorutID = new SelectList(db.Courts, "CourtID", "CourtName"); ViewBag.CorutOfficeID = new SelectList(db.CourtsOffices, "Id", "OfficeName", users_Courts.CorutOfficeID); ViewBag.RoleID = new SelectList(db.Roles, "ID", "Name", users_Courts.RoleID); ViewBag.SupRoleID = new SelectList(db.SubRoles, "ID", "Name", users_Courts.SupRoleID); ViewBag.UserID = new SelectList(db.Users, "ID", "UserName", users_Courts.UserID); ViewBag.CreateAdminID = new SelectList(db.Users, "ID", "UserName", users_Courts.CreateAdminID); ViewBag.UpdateAdminID = new SelectList(db.Users, "ID", "UserName", users_Courts.UpdateAdminID); return(View(users_Courts)); }