public ActionResult Details(int id = 0) { User user = Request <User> .GetAuthItemById(id, "A", "B"); if (user == null) { return(HttpNotFound()); } ViewBag.UserRoles = roles.GetRolesForUser(user.username).ToList(); return(View(user)); }
public ActionResult Details(int id = 0) { User user = users.Find(id); if (user == null) { return(HttpNotFound()); } ViewBag.UserRoles = roles.GetRolesForUser(user.username).ToList(); return(View(user)); }
/// <summary> /// Permanently deletes a user from the database /// </summary> /// <param name="username">Username to delete</param> /// <param name="deleteAllRelatedData">Should or shouldn't delete related user data</param> /// <returns>True if successful. Defaults to false.</returns> public override bool DeleteUser(string username, bool deleteAllRelatedData) { bool ret; try { Snitz.IDAL.IMember dal = Snitz.IDAL.Factory <IDAL.IMember> .Create("Member"); MemberInfo m = dal.GetByName(username).SingleOrDefault(); dal.Delete(m); IRoles roleDal = Factory <IRoles> .Create("Role"); roleDal.RemoveUsersFromRoles(new[] { username }, roleDal.GetRolesForUser(username)); if (deleteAllRelatedData) { IMember membershipDal = Factory <IMember> .Create("Member"); membershipDal.DeleteProfile(m); } // Nothing was thrown, so go ahead and return true ret = true; } catch { // Couldn't find the user or was not able to delete ret = false; } return(ret); }
public static string[] GetRolesForUser(string username) { IRoles dal = Snitz.Membership.Helpers.Factory <IRoles> .Create("Role"); return(dal.GetRolesForUser(username)); }