예제 #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");
            }
        }
예제 #2
0
        public static void insertContact(ContactDTO contactToSave)
        {
            Contact contact = new Contact();

            contact.LastName = contactToSave.LastName;
            Soql.insert(contact);
        }
예제 #3
0
        /**
         * A simple CRUD Example
         */
        public static void CrudExample()
        {
            Contact contactNew = new Contact {
                LastName = "Jay", EMail = "*****@*****.**"
            };

            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");
            }
        }
예제 #4
0
        public static void Setup()
        {
            Contact contactNew = new Contact();

            contactNew.LastName = "Jay";
            contactNew.Email    = "*****@*****.**";
            Soql.insert(contactNew);
        }
예제 #5
0
        public static void getContactsTest()
        {
            Contact contact = new Contact();

            contact.Email    = randomWithLimit() + "@jay.com";
            contact.Phone    = "111-111=1111";
            contact.LastName = "jay";
            Soql.insert(contact);
            List <Contact> contacts = Demo.getContacts();

            System.assert(contacts.size() > 0);
        }
예제 #6
0
        public PageReference save()
        {
            try
            {
                Soql.insert(contact);
            }
            catch (DmlException e)
            {
                ApexPages.addMessages(e);
            }

            return(null);
        }
예제 #7
0
        public static void updatePhoneTestNotValidEmail()
        {
            Contact contact = new Contact();

            contact.Email    = randomWithLimit() + "@jay.com";
            contact.Phone    = "111-111=1111";
            contact.LastName = "jay";
            Soql.insert(contact);
            Demo.updatePhone(contact.Email, "555-1212");
            List <Contact> contacts = Soql.query <Contact>("SELECT ID, Email, Phone FROM Contact WHERE Email = '@jay.com'");

            System.assertEquals(contacts.size(), 0);
        }
예제 #8
0
        static void testGetIdValue()
        {
            Account a = new Account {
                Name = "Acme"
            };

            Soql.insert(a);
            JSONParse parser = new JSONParse("\"" + a.Id.ToString() + "\"");

            System.assertEquals(a.Id, parser.getIdValue());
            try
            {
                parser = new JSONParse("[1,2,3]");
                parser.getIdValue();
                System.assert(false, "Node is not a valid Id, should have seen an exception about that.");
            }
            catch (JSONParse.InvalidConversionException e)
            {
                System.assertEquals("This value cannot be converted to an Id: [ 1, 2, 3 ]", e.getMessage());
            }
        }