Converting and merging js to c# .
-
I have js code, i need it to convert it to c# and merge with my c# code. Here is the js code:
CheckIfIsEsxisting(caption: string, counter: number): string {
const matchBookmark = this.preferences.bookmarks.find(b => b.caption === caption + '(' + counter + ')');
if (undefined === matchBookmark) {
caption = (caption + '(' + counter + ')');
return caption;
} else {
counter++;
return this.CheckIfIsEsxisting(caption, counter);
}***************************************
dialogRef.afterClosed().subscribe(bookmark => {
if (bookmark) { let matchBookmark = this.preferences.bookmarks.find(b => b.caption === bookmark.caption); if (undefined !== matchBookmark) { const newName = this.CheckIfIsEsxisting(bookmark.caption, 1); bookmark.caption = newName; } this.preferences.bookmarks.push(bookmark);
*************************** Here is my C# Code:
public sealed class UserPreferences
{
public long UserId { get; set; }
public int DashboardTypeId { get; set; }
public List Bookmarks { get; set; }
public List Breadcrumbs { get; set; }
public int SubjectTabOrder { get; set; }
public int ChartDefaultStatistic { get; set; }************************ userPreferencesService.Update(targetUserId, newUserPreference); } { Here is the point: As u see "UserPreferences" itself is a list, and it contains "Bookmarks" list and i need to work on one of the Bookmarks which is in "Bookmark list". I know I have to use Linq but confused with changing the js code and also use it in my c#. Would u please help? Regards.