コード例 #1
0
        public async Task <ActionResult> AuditRepair(string button, DashboardInspectionDetailsViewModel model)
        {
            var outlookToken = await O365Util.GetAccessToken(Capabilities.Mail);

            var sharePointToken = await O365Util.GetAccessToken(ServiceResources.DemoSite);

            var outlookClient = await O365Util.GetOutlookClient(Capabilities.Mail);

            Dashboard dashboardModel = new Dashboard(sharePointToken);

            var result = button == "Approve" ? ApprovalResult.Approved : ApprovalResult.Rejected;

            var tasksService = new TasksService(sharePointToken);
            await tasksService.CompleteRepairApprovalTask(model.incidentId, result);

            if (result == ApprovalResult.Approved)
            {
                await dashboardModel.ApproveRepair(model.incidentId);

                //This is the pattern you would use to send email from O365 APIs.  These emails are sent via the mobile apps.
                //var emailService = new EmailService(sharePointToken, Server.MapPath("/"));
                //var emailMessage = await emailService.ComposeRepairCompletedEmailMessage(model.incidentId);
                //await outlookClient.Me.SendMailAsync(emailMessage, true);
            }
            return(new RedirectResult("/Dashboard/Index"));
        }