/** * A simple CRUD Example */ public static void crudExample() { // Contact contactNew = new Contact(LastName = 'Jay', Email = '*****@*****.**'); Contact contactNew = new Contact(); Soql.Insert(contactNew); System.debug(contactNew.Id); List <Contact> contacts = Soql.Query <Contact>("SELECT Id, Email FROM Contact WHERE Id = :contactNew.Id", contactNew.Id); foreach (Contact c in contacts) { System.debug(c.Email); c.Email = "*****@*****.**"; } Soql.Update(contacts); contacts = Soql.Query <Contact>("SELECT Id, Email FROM Contact WHERE Id = :contactNew.Id", contactNew.Id); foreach (Contact c in contacts) { System.debug(c.Email); } Soql.Delete(contacts); contacts = Soql.Query <Contact>("SELECT Id, Email FROM Contact WHERE Id = :contactNew.Id", contactNew.Id); if (contacts.isEmpty()) { System.debug("Delete Worked"); } }
public static void insertContact(ContactDTO contactToSave) { Contact contact = new Contact(); contact.LastName = contactToSave.LastName; Soql.Insert(contact); }
public static void setup() { Contact contactNew = new Contact(); contactNew.LastName = "Jay"; contactNew.Email = "*****@*****.**"; Soql.Insert(contactNew); }
public PageReference save() { try { Soql.Insert(contact); } catch (DmlException e) { ApexPages.addMessages(e); } return(null); }