-
-
Save AdityaPavanVempati/9110f1e59d5e2485590f8e078e71bb71 to your computer and use it in GitHub Desktop.
This is the Controller for Bookmark Page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BookmarksController { | |
public List<Bookmark__c> Bookmarks {get;set;} | |
public BookmarksController() { | |
Bookmarks = new List<Bookmark__c>(); | |
Bookmarks = [ | |
SELECT Name | |
,URL__c | |
,Short_URL__c | |
,Category__c | |
FROM Bookmark__c | |
]; | |
} | |
@RemoteAction | |
public static void saveBookmark( String name, String category, String url ) { | |
Bookmark__c bm = new Bookmark__c(); | |
bm.Name = name; | |
bm.Category__c = category; | |
bm.URL__c = url; | |
INSERT bm; | |
} | |
@RemoteAction | |
public static void deleteBookmark( String id ) { | |
Bookmark__c bm = [ | |
SELECT Id | |
FROM Bookmark__c | |
WHERE Id = :id | |
]; | |
DELETE bm; | |
} | |
@RemoteAction | |
public static void shortenUrl( String url,String id ) { | |
GoogleUrlShortener.shortenURL( url, id ); | |
} | |
@RemoteAction | |
public static void updateBookmark( String id, String name, String category, String url ) { | |
Bookmark__c bm = new Bookmark__c(); | |
bm.Id = id; | |
bm.Name = name; | |
bm.Category__c = category; | |
bm.URL__c = url; | |
UPDATE bm; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment