コード例 #1
0
        public async Task <ActionResult> LeadEdit(Lead lead)
        {
            // TODO: Resolve Edit failures with ID
            // Ensure the user is authenticated
            if (!SalesforceService.IsUserLoggedIn())
            {
                // Should include a state argument to the URI so that when the dance is done, we can redirect to the page that we were requesting
                string myUri = SalesforceOAuthRedirectHandler.AuthorizationUri.ToString() + "&state=" + this.Url.RequestContext.HttpContext.Request.RawUrl;
                return(this.Redirect(myUri));
            }
            // Initialize the Force client
            SalesforceService service = new SalesforceService();
            ForceClient       client  = service.GetForceClient();

            var success = await client.UpdateAsync("Lead", lead.Id, lead);

            if (success.errors == null)
            {
                return(RedirectToAction("LeadList"));
            }
            else
            {
                return(View(lead));
            }
        }
コード例 #2
0
        public async Task <ActionResult> LeadEdit(string id)
        {
            // Ensure the user is authenticated
            if (!SalesforceService.IsUserLoggedIn())
            {
                // Should include a state argument to the URI so that when the dance is done, we can redirect to the page that we were requesting
                string myUri = SalesforceOAuthRedirectHandler.AuthorizationUri.ToString() + "&state=" + this.Url.RequestContext.HttpContext.Request.RawUrl;
                return(this.Redirect(myUri));
            }

            // Initalize the Force client
            SalesforceService service = new SalesforceService();
            ForceClient       client  = service.GetForceClient();

            Lead lead = await client.QueryByIdAsync <Lead>("Lead", id);

            return(View(lead));
        }
コード例 #3
0
        //
        // GET: /Lead/

        public async Task <ActionResult> LeadList()
        {
            // Ensure the user is authenticated
            if (!SalesforceService.IsUserLoggedIn())
            {
                // Should include a state argument to the URI so that when the dance is done, we can redirect to the page that we were requesting
                string myUri = SalesforceOAuthRedirectHandler.AuthorizationUri.ToString() + "&state=" + this.Url.RequestContext.HttpContext.Request.RawUrl;
                return(this.Redirect(myUri));
            }
            // Initialize the Force client
            SalesforceService service = new SalesforceService();
            ForceClient       client  = service.GetForceClient();

            // Query just the properties we need to display the selection with SOQL
            // Querying all properties would waste bandwidth and performance
            QueryResult <Lead> leads =
                await client.QueryAsync <Lead>("SELECT Id, FirstName, LastName,  City, State, Country From Lead");

            return(View(leads.records));
        }