Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Converting and merging js to c# .

Converting and merging js to c# .

Scheduled Pinned Locked Moved C#
csharpjavascriptlinqhelpquestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Afi_sh
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups