public async Task <ActionResult> Create(FormCollection collection)
        {
            try
            {
                string            userObjId  = System.Security.Claims.ClaimsPrincipal.Current.FindFirst("http://schemas.microsoft.com/identity/claims/objectidentifier").Value;
                SessionTokenCache tokenCache = new SessionTokenCache(userObjId, HttpContext);

                string     tenantId    = System.Security.Claims.ClaimsPrincipal.Current.FindFirst("http://schemas.microsoft.com/identity/claims/tenantid").Value;
                string     authority   = string.Format(ConfigurationManager.AppSettings["ida:AADInstance"], tenantId, "");
                AuthHelper authHelper  = new AuthHelper(authority, ConfigurationManager.AppSettings["ida:AppId"], ConfigurationManager.AppSettings["ida:AppSecret"], tokenCache);
                string     accessToken = await authHelper.GetUserAccessToken(Url.Action("Index", "Home", null, Request.Url.Scheme));

                await ExcelApiHelper.CreateDonation(
                    accessToken,
                    collection["Date"],
                    collection["Amount"],
                    collection["Organization"]);

                return(RedirectToAction("Index"));
            }
            catch
            {
                //Handle error
            }

            return(View());
        }
        public async Task <ActionResult> Create(FormCollection collection)
        {
            try
            {
                string            userObjId  = System.Security.Claims.ClaimsPrincipal.Current.FindFirst("http://schemas.microsoft.com/identity/claims/objectidentifier").Value;
                SessionTokenCache tokenCache = new SessionTokenCache(userObjId, HttpContext);

                string accessToken = await SampleAuthProvider.Instance.GetUserAccessTokenAsync();

                await ExcelApiHelper.CreateToDoItem(
                    accessToken,
                    collection["Title"],
                    collection["PriorityDD"],
                    collection["StatusDD"],
                    collection["PercentComplete"],
                    collection["StartDate"],
                    collection["EndDate"],
                    collection["Notes"]);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Пример #3
0
        //
        // GET: ToDoList
        public async Task <ActionResult> Index()
        {
            string            userObjId  = System.Security.Claims.ClaimsPrincipal.Current.FindFirst("http://schemas.microsoft.com/identity/claims/objectidentifier").Value;
            SessionTokenCache tokenCache = new SessionTokenCache(userObjId, HttpContext);

            string accessToken = await SampleAuthProvider.Instance.GetUserAccessTokenAsync();

            return(View(await ExcelApiHelper.GetDonations(accessToken)));
        }
        //
        // GET: ToDoList
        public async Task <ActionResult> Index()
        {
            string            userObjId  = System.Security.Claims.ClaimsPrincipal.Current.FindFirst("http://schemas.microsoft.com/identity/claims/objectidentifier").Value;
            SessionTokenCache tokenCache = new SessionTokenCache(userObjId, HttpContext);

            string     tenantId    = System.Security.Claims.ClaimsPrincipal.Current.FindFirst("http://schemas.microsoft.com/identity/claims/tenantid").Value;
            string     authority   = string.Format(ConfigurationManager.AppSettings["ida:AADInstance"], tenantId, "");
            AuthHelper authHelper  = new AuthHelper(authority, ConfigurationManager.AppSettings["ida:AppId"], ConfigurationManager.AppSettings["ida:AppSecret"], tokenCache);
            string     accessToken = await authHelper.GetUserAccessToken(Url.Action("Index", "Home", null, Request.Url.Scheme));

            return(View(await ExcelApiHelper.GetDonations(accessToken)));
        }
Пример #5
0
        public async Task <ActionResult> Create(FormCollection collection)
        {
            try
            {
                string            userObjId  = System.Security.Claims.ClaimsPrincipal.Current.FindFirst("http://schemas.microsoft.com/identity/claims/objectidentifier").Value;
                SessionTokenCache tokenCache = new SessionTokenCache(userObjId, HttpContext);

                string accessToken = await SampleAuthProvider.Instance.GetUserAccessTokenAsync();

                await ExcelApiHelper.CreateDonation(
                    accessToken,
                    collection["Date"],
                    collection["Amount"],
                    collection["Organization"]);

                return(RedirectToAction("Index"));
            }
            catch
            {
                //Handle error
            }

            return(View());
        }