/// <summary> /// Handles the UniGrid's OnAction event. /// </summary> /// <param name="actionName">Name of item (button) that throws event</param> /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param> protected void gridElem_OnAction(string actionName, object actionArgument) { RaiseOnCheckPermissions(PERMISSION_MANAGE, this); switch (actionName) { case "remove": FriendInfoProvider.DeleteFriendInfo(ValidationHelper.GetInteger(actionArgument, 0)); gridElem.ReloadData(); break; } }
/// <summary> /// Handles the UniGrid's OnAction event. /// </summary> /// <param name="actionName">Name of item (button) that throws event</param> /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param> protected void gridElem_OnAction(string actionName, object actionArgument) { RaiseOnCheckPermissions(PERMISSION_MANAGE, this); FriendInfo fi = FriendInfoProvider.GetFriendInfo(ValidationHelper.GetInteger(actionArgument, 0)); if (fi != null) { switch (actionName) { case "remove": if (fi.FriendStatus != FriendshipStatusEnum.Rejected) { FriendInfoProvider.DeleteFriendInfo(fi); } gridElem.ReloadData(); break; } } }
/// <summary> /// Deletes all friends of "My new user". Called when the "Delete friends" button is pressed. /// Expects the CreateFriend method to be run first. /// </summary> private bool DeleteFriends() { // Get the user UserInfo friend = UserInfoProvider.GetUserInfo("MyNewFriend"); if (friend != null) { // Prepare the parameters string where = "FriendRequestedUserID = " + friend.UserID; // Get all user's friendships DataSet friends = FriendInfoProvider.GetFriends(where, null); if (!DataHelper.DataSourceIsEmpty(friends)) { // Delete all the friendships foreach (DataRow friendDr in friends.Tables[0].Rows) { FriendInfo deleteFriend = new FriendInfo(friendDr); FriendInfoProvider.DeleteFriendInfo(deleteFriend); } } else { // Change the info message apiDeleteFriends.InfoMessage = "The user 'My new friend' doesn't have any friends. The user has been deleted."; } // Finally delete the user "My new friend" UserInfoProvider.DeleteUser(friend); return(true); } return(false); }
protected void btnRemoveSelected_Click(object sender, EventArgs e) { // If there user selected some items if (gridElem.SelectedItems.Count > 0) { RaiseOnCheckPermissions(PERMISSION_MANAGE, this); // Get all needed friendships DataSet friendships = FriendInfoProvider.GetFriends() .WhereIn("FriendID", gridElem.SelectedItems.Select(id => ValidationHelper.GetInteger(id, 0)).ToList()); if (!DataHelper.DataSourceIsEmpty(friendships)) { // Delete all these friendships foreach (DataRow friendship in friendships.Tables[0].Rows) { FriendInfoProvider.DeleteFriendInfo(new FriendInfo(friendship)); } } gridElem.ResetSelection(); // Reload grid gridElem.ReloadData(); } }