public static bool UpdataAudit(HotelManag hotel) { var re = db.HotelManag.Find(hotel.HotelID); re.HotelRatify = hotel.HotelRatify; if (re.HotelRatify == true) { var userurel = db.UserMessage.Where(s => s.HotelID == hotel.HotelID).FirstOrDefault(); var usme = db.UserMessage.Find(userurel.UserID); usme.UserGrade = "管理员"; user_roles user_Roles = new user_roles(); user_Roles.UserPhone = usme.UserPhone; user_Roles.user_roles1 = usme.UserGrade; db.user_roles.Add(user_Roles); } else { var userurel = db.UserMessage.Where(s => s.HotelID == hotel.HotelID).FirstOrDefault(); var usme = db.UserMessage.Find(userurel.UserID); usme.UserGrade = "用户"; var usrolfirst = db.user_roles.Where(s => s.UserPhone == usme.UserPhone).FirstOrDefault(); var usrol = db.user_roles.Find(usrolfirst.user_rolesID); db.user_roles.Remove(usrol); } return(db.SaveChanges() > 0); }
public ActionResult Permission(int?UserID, string UserGrade, string UserPhone, string username) { if (username != null) { var bs = db.UserMessage.Where(s => s.UserPhone.Contains(username)).ToList(); return(View(bs)); } if (UserGrade == null) { UserMessage userMessage = db.UserMessage.Where(t => t.UserID == UserID).FirstOrDefault(); if (userMessage.User_status == true) { userMessage.User_status = false; } else { userMessage.User_status = true; } var user = db.UserMessage.Find(UserID); user.User_status = userMessage.User_status; db.SaveChanges(); return(RedirectToAction("Permission")); //return Content("<script>alert('jj');location.href='Permission'<script>"); } else { UserMessage userMessage = db.UserMessage.Where(t => t.UserID == UserID).FirstOrDefault(); if (userMessage.UserGrade == "用户" && (UserGrade == "管理员" || UserGrade == "超级管理员")) { user_roles user_Roles = new user_roles(); user_Roles.UserPhone = UserPhone; user_Roles.user_roles1 = UserGrade; db.user_roles.Add(user_Roles); userMessage.UserGrade = UserGrade; db.SaveChanges(); return(RedirectToAction("Permission")); } else if ((userMessage.UserGrade == "管理员" || userMessage.UserGrade == "超级管理员") && UserGrade == "用户") { user_roles user_Roles = db.user_roles.Where(t => t.UserPhone == UserPhone).FirstOrDefault(); db.user_roles.Remove(user_Roles); userMessage.UserGrade = UserGrade; db.SaveChanges(); return(RedirectToAction("Permission")); } else if ((userMessage.UserGrade == "管理员" || userMessage.UserGrade == "超级管理员") && (UserGrade == "管理员" || UserGrade == "超级管理员")) { user_roles user_Roles = db.user_roles.Where(t => t.UserPhone == UserPhone).FirstOrDefault(); user_Roles.user_roles1 = UserGrade; userMessage.UserGrade = UserGrade; db.SaveChanges(); return(RedirectToAction("Permission")); } else { userMessage.UserGrade = UserGrade; db.SaveChanges(); return(RedirectToAction("Permission")); } //var user = db.UserMessage.Find(UserID); //user.UserGrade = userMessage.UserGrade; } }
public DisplayUserModell(users user, users_data user_data, user_roles role) { this.user = user; this.user_data = user_data; this.role = role; }