public static Boolean canEdit(User u) { var user = m.LoggedInUser(); if (user != null && (user == u.Username || Roles.GetRolesForUser().Intersect(admin).Count() > 0)) { return true; } return false; }
public ActionResult Create(User user) { if (ModelState.IsValid) { context.Users.Add(user); context.SaveChanges(); return RedirectToAction("Index"); } return View(user); }
public ActionResult Edit(User user, String role) { if (ModelState.IsValid) { context.Entry(user).State = EntityState.Modified; context.SaveChanges(); var roles = Roles.GetRolesForUser(user.Username); if (role != "-1") { if (roles.Length != 0) { Roles.RemoveUserFromRoles(user.Username, roles); } Roles.AddUserToRole(user.Username, role); } return RedirectToAction("Index"); } return View(user); }
private bool autoApprove(User u) { //Editor status or higher if (Roles.GetRolesForUser().Intersect(new String[] { "Admin", "Editor" }).Count() > 0) { return true; } else if (u.Articles.Count() >= 5) { return true; } return false; }