public async Task<ActionResult> Index() { var sharePointToken = await AuthenticationHelper.GetAccessTokenAsync(AppSettings.DemoSiteServiceResourceId); Dashboard dashboardModel = new Dashboard(sharePointToken); var model = await dashboardModel.GetDashboardPropertiesViewModelAsync(); return View(model); }
public async Task<ActionResult> Property(int Id) { var sharePointToken = await O365Util.GetAccessToken(ServiceResources.DemoSite); Dashboard dashboardModel = new Dashboard(sharePointToken); var model = await dashboardModel.GetDashboardPropertiesViewModel(Id); return View(model); }
public async Task<ActionResult> InspectionDetails(int id) { var sharePointToken = await AuthenticationHelper.GetAccessTokenAsync(AppSettings.DemoSiteServiceResourceId); var graphService = await AuthenticationHelper.GetGraphServiceAsync(AADAppSettings.GraphResourceUrl); Dashboard dashboardModel = new Dashboard(sharePointToken); var model = await dashboardModel.GetDashboardInspectionDetailsViewModelAsync(graphService, id, User.Identity.Name); if (model == null) return HttpNotFound(); var accessToken = await AuthenticationHelper.GetGraphAccessTokenAsync(); TempData["accesstoken"] = accessToken; await dashboardModel.CheckSubscriptionAsync(graphService, accessToken); return View(model); }
public async Task<ActionResult> AuditRepair(AuditRepairModel model) { var sharePointToken = await AuthenticationHelper.GetAccessTokenAsync(AppSettings.DemoSiteServiceResourceId); Dashboard dashboardModel = new Dashboard(sharePointToken); var tasksService = new TasksService(sharePointToken); await tasksService.CompleteRepairApprovalTaskAsync(model); if (model.Result == ApprovalResult.Approved) await dashboardModel.ApproveRepairAsync(model.IncidentId); return RedirectToAction("Index"); }
public async Task<ActionResult> InspectionDetails(DashboardInspectionDetailsViewModel model) { var sharePointToken = await O365Util.GetAccessToken(ServiceResources.DemoSite); var service = new TasksService(sharePointToken); await service.CompleteRepairAssignmentTask(model.incidentId); var dashboardModel = new Dashboard(sharePointToken); var calendarEvent = await dashboardModel.ScheduleRepair(model); await O365CalendarController.Create(calendarEvent); return RedirectToAction("InspectionDetails", new { id = model.incidentId }); }
public async Task<ActionResult> InspectionDetails(int id) { var outlookToken = await AuthenticationHelper.GetAccessTokenAsync(AADAppSettings.OutlookResourceId); var sharePointToken = AuthenticationHelper.GetAccessTokenAsync(AppSettings.DemoSiteServiceResourceId); var graphService = AuthenticationHelper.GetGraphServiceAsync(); var oneNoteToken = AuthenticationHelper.GetOneNoteAccessTokenAsync(); var oneNoteServiceFactory = new OneNoteServiceFactory(AADAppSettings.OneNoteResourceUrl, await oneNoteToken); Dashboard dashboardModel = new Dashboard(await sharePointToken); var model = await dashboardModel.GetDashboardInspectionDetailsViewModelAsync(await graphService, oneNoteServiceFactory, id, User.Identity.Name); if (model == null) return HttpNotFound(); return View(model); }
public async Task<ActionResult> ScheduleRepair(ScheduleRepairModel model) { var sharePointToken = AuthenticationHelper.GetAccessTokenAsync(AppSettings.DemoSiteServiceResourceId); var graphService = AuthenticationHelper.GetGraphServiceAsync(); var tasksService = new TasksService(await sharePointToken); var dashboardModel = new Dashboard(await sharePointToken); await dashboardModel.UpdateRepairScheduleInfoToIncidentAsync(model) .ContinueWith(async task => await tasksService.CompleteRepairAssignmentTaskAsync(model.IncidentId)); await dashboardModel.ScheduleRepairAsync(await graphService, model); await dashboardModel.CreateGroupRepairEventAsync(await graphService, model); return RedirectToAction("Index"); }
public async Task<ActionResult> InspectionDetails(int Id) { await O365Util.GetAccessToken(Capabilities.Mail); // Prepare Outlook token in advance. var sharePointToken = await O365Util.GetAccessToken(ServiceResources.DemoSite); Dashboard dashboardModel = new Dashboard(sharePointToken); var model = await dashboardModel.GetDashboardInspectionDetailsViewModel(Id); if (model == null) { return new RedirectResult("/Dashboard/Index"); } else if (model.viewName == "schedule a repair") { ViewBag.RepairPeopleList = new SelectList(model.repairPeople, "sl_emailaddress", "Title"); } return View(model); }
public async Task<ActionResult> ScheduleRepair(ScheduleRepairModel model) { model.TimeSlotsSelectedValue = DateTime.ParseExact(string.Format("{0} {1}:00", model.TimeSlotsSelectedDateValue, model.TimeSlotsSelectedHoursValue), "yyyy-MM-dd HH:mm", null); var sharePointToken = AuthenticationHelper.GetAccessTokenAsync(AppSettings.DemoSiteServiceResourceId); var graphService = AuthenticationHelper.GetGraphServiceAsync(AADAppSettings.GraphResourceUrl); var tasksService = new TasksService(await sharePointToken); var dashboardModel = new Dashboard(await sharePointToken); await dashboardModel.UpdateRepairScheduleInfoToIncidentAsync(model) .ContinueWith(async task => await tasksService.CompleteRepairAssignmentTaskAsync(model.IncidentId)); await dashboardModel.ScheduleRepairAsync(await graphService, model); await dashboardModel.CreateGroupRepairEventAsync(await graphService, model); await dashboardModel.CreateO365TaskAsync(await graphService, model); return RedirectToAction("Index"); }
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"); }
public async Task<ActionResult> AnnotateImages(int incidentId) { var sharePointToken = AuthenticationHelper.GetAccessTokenAsync(AppSettings.DemoSiteServiceResourceId); var oneNoteToken = AuthenticationHelper.GetOneNoteAccessTokenAsync(); var graphService = AuthenticationHelper.GetGraphServiceAsync(); var dashboardService = new Dashboard(await sharePointToken); var oneNoteServiceFactory = new OneNoteServiceFactory(AADAppSettings.OneNoteResourceUrl, await oneNoteToken); var pageUrl = await dashboardService.AnnotateImagesAsync(await graphService, oneNoteServiceFactory, Server.MapPath("/"), incidentId); return Redirect(pageUrl); }
public async Task<ActionResult> UploadFile(UploadFileModel model) { if (model.File != null) { var token = AuthenticationHelper.GetAccessTokenAsync(AppSettings.DemoSiteServiceResourceId); var graphService = AuthenticationHelper.GetGraphServiceAsync(); var dashboardService = new Dashboard(await token); await dashboardService.UploadFileAsync(await graphService, model); } return RedirectToAction("InspectionDetails", new { id = model.IncidentId }); }