Thanks for your reply, but I need to check the uniqueness of the value when a member edits his/her properties in the EditProfile.cshtml page... Probably the best way is to create a custom UmbProfileController.
What you mean when you say that you need to check the uniqueness? The user should type this unique value in order to be able to edit his profile? Tell me exactly what you want to do in order to be able to help you.
I have added a "forum nickname" textfield to the Member object, so a member can choose any nickname (different from the username) to use in the forum. I'm able to sync the nickname in Umbraco with the nickname in the forum to provide an unique login between the two websites, but I must be sure that if an Umbraco's member changes his/her nickname, this one must be unique to the Umbraco database (and obviously in the forum database, but they're always in sync)
So the member will submit an id and you want to test if it is unique. Try the following code.
var ms = ApplicationContext.Current.Services.MemberService;
string Value = "Test";
var MembersFound = ms.GetMembersByPropertyValue("UniqueID", Value);
if (MembersFound.Count() == 0)
{
// The id is unique so use it
}
else
{
// The id is not unique so ask user to define a new Unique id
}
The Value variable contains the id defined by the user. You ask all users that has as UniqueID property the value defined by the user. If you find a member with this condition then someone uses this id otherwise it is available.
I have not tested it but it should work. Inform me if you have a problem with this code.
Unique property Value
I've added a simple text property to the Member object. It should be unique so two members cannot have the same value for that property.
How can I accomplish this?
Thanks in advance
I suppose you create the members programmatically. You can get a unique id for each member using the Guid.
Now you can use this ID in order to store it for a Member.
Thanks for your reply, but I need to check the uniqueness of the value when a member edits his/her properties in the EditProfile.cshtml page... Probably the best way is to create a custom UmbProfileController.
What you mean when you say that you need to check the uniqueness? The user should type this unique value in order to be able to edit his profile? Tell me exactly what you want to do in order to be able to help you.
I have added a "forum nickname" textfield to the Member object, so a member can choose any nickname (different from the username) to use in the forum. I'm able to sync the nickname in Umbraco with the nickname in the forum to provide an unique login between the two websites, but I must be sure that if an Umbraco's member changes his/her nickname, this one must be unique to the Umbraco database (and obviously in the forum database, but they're always in sync)
So the member will submit an id and you want to test if it is unique. Try the following code.
The Value variable contains the id defined by the user. You ask all users that has as UniqueID property the value defined by the user. If you find a member with this condition then someone uses this id otherwise it is available.
I have not tested it but it should work. Inform me if you have a problem with this code.
is working on a reply...