Skip to content

Instantly share code, notes, and snippets.

@AdityaPavanVempati
Created April 11, 2016 05:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AdityaPavanVempati/9110f1e59d5e2485590f8e078e71bb71 to your computer and use it in GitHub Desktop.
Save AdityaPavanVempati/9110f1e59d5e2485590f8e078e71bb71 to your computer and use it in GitHub Desktop.
This is the Controller for Bookmark Page
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