Ejemplo n.º 1
0
        /**
         * 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");
            }
        }
Ejemplo n.º 2
0
        public static void insertContact(ContactDTO contactToSave)
        {
            Contact contact = new Contact();

            contact.LastName = contactToSave.LastName;
            Soql.Insert(contact);
        }
Ejemplo n.º 3
0
        public static void setup()
        {
            Contact contactNew = new Contact();

            contactNew.LastName = "Jay";
            contactNew.Email    = "*****@*****.**";
            Soql.Insert(contactNew);
        }
Ejemplo n.º 4
0
        public PageReference save()
        {
            try
            {
                Soql.Insert(contact);
            }
            catch (DmlException e)
            {
                ApexPages.addMessages(e);
            }

            return(null);
        }