public async Task<ActionResult> Edit([Bind(Include = _EventsPostBinding)] Event Event)
 {
     SuccessResponse success = new SuccessResponse();
     try
     {
         success = await SalesforceService
             .MakeAuthenticatedClientRequestAsync(
             async (client) =>
             {
                 success = await client
                 .UpdateAsync("Event", Event.Id, Event);
                 return success;
             }
             );
     }
     catch (Exception e)
     {
         ViewBag.OperationName = "Edit Salesforce Event";
         ViewBag.AuthorizationUrl = SalesforceOAuthRedirectHandler
             .GetAuthorizationUrl(Request.Url.ToString());
         ViewBag.ErrorMessage = e.Message;
     }
     if (ViewBag.ErrorMessage == "AuthorizationRequired")
     {
         return Redirect(ViewBag.AuthorizationUrl);
     }
     if (success.Success)
     {
         return RedirectToAction("Index");
     }
     else
     {
         return View(Event);
     }
 }
 public async Task<ActionResult> Create([Bind(Include = _EventsPostBinding)] Event Event)
 {
     SuccessResponse success = new SuccessResponse();
     String id = String.Empty;
     try
     {
         success = await SalesforceService.MakeAuthenticatedClientRequestAsync(
             async (client) =>
             {
                 return await client.CreateAsync("Event", Event);
             }
             );
         id = success.Id;
     }
     catch (Exception e)
     {
         this.ViewBag.OperationName = "Create Salesforce Event";
         this.ViewBag.AuthorizationUrl = SalesforceOAuthRedirectHandler.GetAuthorizationUrl(this.Request.Url.ToString());
         this.ViewBag.ErrorMessage = e.Message;
     }
     if (this.ViewBag.ErrorMessage == "AuthorizationRequired")
     {
         return Redirect(this.ViewBag.AuthorizationUrl);
     }
     if (this.ViewBag.ErrorMessage == null)
     {
         return RedirectToAction("Index");
     }
     else
     {
         return View(Event);
     }
 }
예제 #3
0
 public async Task<ActionResult> Edit([Bind(Include = _LeadPostBinding)] Lead lead)
 {
     SuccessResponse success = new SuccessResponse();
     try
     {
         success = await SalesforceService.MakeAuthenticatedClientRequestAsync(
             async (client) =>
             {
                 success = await client.UpdateAsync("Lead", lead.Id, lead);
                 return success;
             }
             );
     }
     catch (Exception e)
     {
         this.ViewBag.OperationName = "Edit Salesforce Lead";
         this.ViewBag.AuthorizationUrl = SalesforceOAuthRedirectHandler.GetAuthorizationUrl(this.Request.Url.ToString());
         this.ViewBag.ErrorMessage = e.Message;
     }
     if (this.ViewBag.ErrorMessage == "AuthorizationRequired")
     {
         return Redirect(this.ViewBag.AuthorizationUrl);
     }
     if (success.Success == "true")
     {
         return RedirectToAction("Index");
     }
     else
     {
         return View(lead);
     }
 }