// GET: Contacts
        public async Task <ActionResult> Index()
        {
            IEnumerable <Contact> selectedContacts = Enumerable.Empty <Contact>();

            try
            {
                selectedContacts = await SalesforceService.MakeAuthenticatedClientRequestAsync(
                    async (client) =>
                {
                    QueryResult <Contact> contacts =
                        await client.QueryAsync <Contact>("SELECT Id, Salutation, FirstName, LastName, MailingCity, MailingState, MailingCountry From Contact");

                    return(contacts.Records);
                }
                    );

                foreach (var item in selectedContacts)
                {
                    db.Contacts.Add(item);
                }
                db.SaveChanges();
                db.Dispose();
            }
            catch (Exception e)
            {
                this.ViewBag.OperationName    = "query Salesforce Contacts";
                this.ViewBag.AuthorizationUrl = SalesforceOAuthRedirectHandler.GetAuthorizationUrl(this.Request.Url.ToString());
                this.ViewBag.ErrorMessage     = e.Message;
            }
            if (this.ViewBag.ErrorMessage == "AuthorizationRequired")
            {
                return(Redirect(this.ViewBag.AuthorizationUrl));
            }
            return(View(selectedContacts));
        }
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         db.Dispose();
     }
     base.Dispose(disposing);
 }