//public ActionResult SetMod(long? id) //{ // if (id == null) // { // return new HttpStatusCodeResult(HttpStatusCode.BadRequest); // } // User user = db.Users.Find(id); // if (user == null) // { // return HttpNotFound(); // } // return View(user); //} public ActionResult SetMod(int UserID, int AdminID) { List<User> listUser = new List<User>(); var userChange = db.Users.Include(u=>u.EventFollows); userChange = userChange.Where(u => u.UserID == UserID); listUser = userChange.ToList(); TrackingUser track = new TrackingUser(); track.ActorID = AdminID; track.ReceiverID = UserID; //senderType, receiverType: //user, mod, admin: 0 // event: 1, report: 2, appeal: 3 track.ActionTime = DateTime.Now; if (userChange != null) { if (listUser[0].UserRoles ==0){ listUser[0].UserRoles = 1; track.ActionID = 5; db.TrackingUsers.Add(track); } else { listUser[0].UserRoles = 0; track.ActionID = 6; db.TrackingUsers.Add(track); } // db.Entry(userChange).State = EntityState.Modified; db.SaveChanges(); } userChange = db.Users.Include(u => u.EventFollows); return View("ManageUsers", userChange); }
public ActionResult Lock(int UserID, int AdminID) { List<User> listUser = new List<User>(); var userChange = db.Users.Include(u => u.EventFollows); userChange = userChange.Where(u => u.UserID == UserID); listUser = userChange.ToList(); TrackingUser track = new TrackingUser(); track.ActorID = AdminID; track.ReceiverID = UserID; track.ActionTime = DateTime.Now; if (userChange != null) { if (listUser[0].AccountStatus == true) { listUser[0].AccountStatus = false; track.ActionID = 1; db.TrackingUsers.Add(track); } else { listUser[0].AccountStatus = true; track.ActionID = 2; db.TrackingUsers.Add(track); } // db.Entry(userChange).State = EntityState.Modified; db.SaveChanges(); } userChange = db.Users.Include(u => u.EventFollows); return View("ManageUsers", userChange); }