Ejemplo n.º 1
0
        // Upload user information to Excel workbook "demo.xslx."
        public async Task <ActionResult> UploadInfoToExcel()
        {
            try
            {
                // Get an access token.
                string accessToken = await SampleAuthProvider.Instance.GetUserAccessTokenAsync();

                // Upload user info to Excel file "demo.xslx".
                ViewBag.Message = await graphService.AddInfoToExcel(accessToken, Request.Form["user-name"], Request.Form["user-email"]);

                ViewBag.Name  = Request.Form["user-name"];
                ViewBag.Email = Request.Form["user-email"];
                return(View("Graph"));
            }
            catch (Exception e)
            {
                if (e.Message == Resource.Error_AuthChallengeNeeded)
                {
                    return(new EmptyResult());
                }
                return(RedirectToAction("Index", "Error", new { message = Resource.Error_Message + Request.RawUrl + ": " + e.Message }));
            }
        }