Пример #1
0
        public async Task <DashboardInspectionDetailsViewModel> GetDashboardInspectionDetailsViewModel(int incidentId)
        {
            var incident = await GetIncidentById(incidentId);

            Inspection inspection = null;

            if (incident.sl_inspectionIDId == null)
            {
                return(null);
            }

            inspection = await GetInspectionById(incident.sl_inspectionIDId.Value);

            DashboardInspectionDetailsViewModel viewModel = new DashboardInspectionDetailsViewModel();

            viewModel.incidentId = incidentId;
            viewModel.inspection = inspection;

            if (inspection.sl_propertyID != null)
            {
                if (inspection.sl_propertyID.Id > 0)
                {
                    inspection.sl_propertyID.propertyImgUrl = await GetPropertyPhoto(inspection.sl_propertyID.Id);
                }
            }
            viewModel.incident = incident;

            if (incident.sl_repairScheduled == null)
            {
                viewModel.viewName     = "schedule a repair";
                viewModel.repairPeople = await GetRepairPeople();

                viewModel.roomInspectionPhotos = await GetInspectionPhotos(inspection.Id);

                viewModel.inspectionComment = await GetInspectionComment(inspection.Id);
            }
            else if (incident.sl_repairCompleted == null)
            {
                viewModel.viewName             = "repair in progress";
                viewModel.roomInspectionPhotos = await GetInspectionPhotos(inspection.Id);

                viewModel.inspectionComment = await GetInspectionComment(inspection.Id);
            }
            else if (incident.sl_repairApproved == null)
            {
                viewModel.viewName             = "repair complete";
                viewModel.roomInspectionPhotos = await GetInspectionPhotos(inspection.Id);

                viewModel.inspectionComment = await GetInspectionComment(inspection.Id);

                viewModel.repairPhotos = await GetRepairPhotos(incidentId);
            }

            return(viewModel);
        }
        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 });
        }
Пример #3
0
        public async Task <Event> ScheduleRepair(DashboardInspectionDetailsViewModel model)
        {
            DateTime             repairDate = DateTime.Parse(model.timeSlotsSelectedValue);
            ScheduleRepairUpdate updateJson = new ScheduleRepairUpdate();

            updateJson.sl_dispatcherComments = model.dispatcherComments;
            updateJson.sl_repairScheduled    = repairDate.ToUniversalTime();
            updateJson.sl_repairPerson       = model.repairPeopleSelectedValue;
            updateJson.__metadata            = new metadata {
                type = "SP.Data.IncidentsListItem"
            };
            await SuiteLevelWebApp.Utils.RestHelper.PostRestDataToDemoSite("/_api/lists/GetByTitle('Incidents')/Items(" + model.incidentId + ")", JsonConvert.SerializeObject(updateJson), _token);

            var incident = await GetIncidentById(model.incidentId);

            var repairPeople = await GetRepairPeopleByEmailAddress(model.repairPeopleSelectedValue);

            //create a new event
            Attendee attendee = new Attendee
            {
                EmailAddress = new EmailAddress
                {
                    Address = repairPeople.sl_emailaddress,
                    Name    = repairPeople.Title
                },
                Type = AttendeeType.Required
            };

            Attendee[] attendees = new Attendee[1];
            attendees[0] = attendee;

            Event newEvent = new Event
            {
                Subject = "Repair Event",
                Body    = new ItemBody
                {
                    Content     = incident.sl_dispatcherComments,
                    ContentType = BodyType.HTML
                },
                ShowAs   = FreeBusyStatus.Busy,
                Start    = repairDate.ToUniversalTime(),
                End      = (repairDate.AddHours(1)).ToUniversalTime(),
                Location = new Location
                {
                    DisplayName = incident.sl_roomID.Title
                },
                Attendees = attendees
            };

            return(newEvent);
        }
        public async Task<DashboardInspectionDetailsViewModel> GetDashboardInspectionDetailsViewModel(int incidentId)
        {
            var incident = await GetIncidentById(incidentId);
            Inspection inspection = null;

            if (incident.sl_inspectionIDId == null)
            {
                return null;
            }

            inspection = await GetInspectionById(incident.sl_inspectionIDId.Value);

            DashboardInspectionDetailsViewModel viewModel = new DashboardInspectionDetailsViewModel();

            viewModel.incidentId = incidentId;
            viewModel.inspection = inspection;

            if (inspection.sl_propertyID != null)
            {
                if (inspection.sl_propertyID.Id > 0)
                {
                    inspection.sl_propertyID.propertyImgUrl = await GetPropertyPhoto(inspection.sl_propertyID.Id);
                }
            }
            viewModel.incident = incident;

            if (incident.sl_repairScheduled == null)
            {
                viewModel.viewName = "schedule a repair";
                viewModel.repairPeople = await GetRepairPeople();
                viewModel.roomInspectionPhotos = await GetInspectionPhotos(inspection.Id);
                viewModel.inspectionComment = await GetInspectionComment(inspection.Id);
            }
            else if (incident.sl_repairCompleted == null)
            {
                viewModel.viewName = "repair in progress";
                viewModel.roomInspectionPhotos = await GetInspectionPhotos(inspection.Id);
                viewModel.inspectionComment = await GetInspectionComment(inspection.Id);
            }
            else if (incident.sl_repairApproved == null)
            {
                viewModel.viewName = "repair complete";
                viewModel.roomInspectionPhotos = await GetInspectionPhotos(inspection.Id);
                viewModel.inspectionComment = await GetInspectionComment(inspection.Id);
                viewModel.repairPhotos = await GetRepairPhotos(incidentId);
            }

            return viewModel;
        }
        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 <DashboardInspectionDetailsViewModel> GetDashboardInspectionDetailsViewModelAsync(Graph.GraphService graphService, OneNoteServiceFactory oneNoteServiceFactory, int incidentId, string CurrentUser)
        {
            Task <Graph.IUser[]> getRepairPeople = null;
            Task <RepairPhoto[]> getRepairPhotos = null;

            var videos = GetVideosAsync(AppSettings.VideoPortalIncidentsChannelName, incidentId);

            var incident = await GetIncidentByIdAsync(incidentId);

            if (incident.sl_inspectionIDId == null)
            {
                return(null);
            }

            var property       = incident.sl_propertyID;
            var propertyImgUrl = GetPropertyPhotoAsync(property.Id);

            var inspectionID        = incident.sl_inspectionIDId.Value;
            var inspection          = GetInspectionByIdAsync(inspectionID);
            var getInspectionPhotos = GetInspectionPhotosAsync(inspectionID);

            var incidentStatus = incident.sl_status;

            if (incidentStatus == "Pending Assignment")
            {
                getRepairPeople = graphService.GetGroupMembersAsync("Repair People");
            }
            if (incidentStatus == "Repair Pending Approval" || incidentStatus == "Repair Approved")
            {
                getRepairPhotos = GetRepairPhotosAsync(incidentId);
            }

            var unifiedGroupFetcher = graphService.groups.GetById(property.sl_group);
            var unifiedGroup        = unifiedGroupFetcher.ExecuteAsync();
            var groupFiles          = GetGroupFilesAsync(unifiedGroupFetcher, (await unifiedGroup).mailNickname);
            var groupConversations  = GetConversationsAsync(unifiedGroupFetcher, (await unifiedGroup).mail);

            var notebookName   = (await unifiedGroup).displayName + " Notebook";;
            var oneNoteService = oneNoteServiceFactory.CreateOneNoteServiceForUnifiedGroup(await unifiedGroup);
            var notebook       = GetOrCreateNoteBook(await oneNoteService, notebookName);
            var pages          = (await notebook) != null
                ? GetOneNotePagesAsync(await oneNoteService, (await notebook).Id, property.Title, incidentId)
                : Task.FromResult(new HyperLink[0]);

            // Repair people are included in property group.
            // Before we get members of a group, we must make sure that repair people have been retrieved.
            // Otherwise, we'll get an error:
            //         The context is already tracking a different entity with the same resource Uri.
            if (getRepairPeople != null)
            {
                await getRepairPeople;
            }
            var groupMembers = graphService.GetGroupMembersAsync(unifiedGroupFetcher);

            var recentEarliestDateTime = new DateTimeOffset(DateTime.UtcNow).AddDays(-7);
            var recentDocuments        = (await groupFiles)
                                         .Where(i => i.dateTimeLastModified > recentEarliestDateTime)
                                         .ToList();

            property.propertyImgUrl = await propertyImgUrl;

            var isCurrentUserDispatcher = CurrentUser == AppSettings.DispatcherEmail;


            var viewModel = new DashboardInspectionDetailsViewModel
            {
                viewName             = IncidentStatusViewMappings[incidentStatus],
                PropertyDetail       = property,
                incidentId           = incidentId,
                incident             = incident,
                UnifiedGroupNickName = (await unifiedGroup).mailNickname,
                UnifiedGroupId       = (await unifiedGroup).objectId,
                UnifiedGroupEmail    = (await unifiedGroup).mail,
                inspection           = await inspection,
                videos = await videos,
                files  = (await groupFiles)
                         .Select(i => HyperLink.Create(i.name, i.webUrl))
                         .ToArray(),
                recentDocuments = recentDocuments
                                  .Select(i => HyperLink.Create(i.name, i.webUrl))
                                  .ToArray(),
                members = await groupMembers,
                roomInspectionPhotos = await getInspectionPhotos,
                inspectionComment    = await GetInspectionCommentAsync(inspectionID, incident.sl_roomID.Id),
                //tasks = await GetTaskHyperLinksAsync(unifiedGroup)
                repairPeople    = getRepairPeople != null ? await getRepairPeople : new Graph.IUser[0],
                repairPhotos    = getRepairPhotos != null ? await getRepairPhotos : new RepairPhoto[0],
                DispatcherMails = isCurrentUserDispatcher ? await GetMailsForDispatcherAsync(graphService, CurrentUser) : new HyperLink[0],
                oneNoteUrl      = (await notebook) != null ? (await notebook).Url : "",
                oneNotePages    = await pages,
                conversations   = await groupConversations
            };

            return(viewModel);
        }
Пример #7
0
        public async Task <DashboardInspectionDetailsViewModel> GetDashboardInspectionDetailsViewModelAsync(GraphServiceClient graphService, int incidentId, string CurrentUser)
        {
            Graph.User[]         getRepairPeople = null;
            Task <RepairPhoto[]> getRepairPhotos = null;

            var videos = await GetVideosAsync(AppSettings.VideoPortalIncidentsChannelName, incidentId);

            var incident = await GetIncidentByIdAsync(incidentId);

            if (incident.sl_inspectionIDId == null)
            {
                return(null);
            }

            var property       = incident.sl_propertyID;
            var propertyImgUrl = GetPropertyPhotoAsync(property.Id);

            var inspectionID = incident.sl_inspectionIDId.Value;
            var inspection   = await GetInspectionByIdAsync(inspectionID);

            var getInspectionPhotos = await GetInspectionPhotosAsync(inspectionID);

            var incidentStatus = incident.sl_status;

            if (incidentStatus == "Pending Assignment")
            {
                getRepairPeople = await graphService.GetGroupMembersAsync("Repair People");
            }


            if (incidentStatus == "Repair Pending Approval" || incidentStatus == "Repair Approved")
            {
                getRepairPhotos = GetRepairPhotosAsync(incidentId);
            }

            var unifiedGroupFetcher = graphService.Groups[property.sl_group];
            var unifiedGroup        = await unifiedGroupFetcher.Request().GetAsync();

            var groupFiles = await GetGroupFilesAsync(unifiedGroupFetcher);

            var groupConversations = await GetConversationsAsync(unifiedGroupFetcher, unifiedGroup.Mail);

            var propertyExcelWorkbook = await ExcelService.GetPropertyExcelWorkbooksAsync(property.sl_group);

            var notebook = await OneNoteService.GetNoteBookByNameAsync(unifiedGroup, unifiedGroup.DisplayName + " Notebook");

            var oneNotePages = (notebook != null)
                ? await Services.OneNoteService.GetOneNotePagesAsync(graphService, unifiedGroup)
                : await Task.FromResult(new HyperLink[0]);

            var groupMembers = await graphService.GetGroupMembersAsync(unifiedGroupFetcher);

            var plan = await PlanService.GetPlanAsync(unifiedGroup);

            List <O365Task> tasks = new List <O365Task>();

            if (plan != null)
            {
                tasks = await GetO365TasksAsync(graphService, plan);
            }

            var recentEarliestDateTime = new DateTimeOffset(DateTime.UtcNow).AddDays(-7);
            var recentDocuments        = groupFiles
                                         .Where(i => i.dateTimeLastModified > recentEarliestDateTime)
                                         .ToList();

            property.propertyImgUrl = await propertyImgUrl;

            var isCurrentUserDispatcher = CurrentUser == AppSettings.DispatcherEmail;

            var bannotateImage = true;

            if (notebook == null || string.IsNullOrEmpty(notebook.oneNoteWebUrl) ||
                oneNotePages.Where(x => x.Title.ToString().Equals(string.Format("Incident[{0}]", incidentId))).Count() > 0)
            {
                bannotateImage = false;
            }
            var viewModel = new DashboardInspectionDetailsViewModel
            {
                viewName             = IncidentStatusViewMappings[incidentStatus],
                PropertyDetail       = property,
                incidentId           = incidentId,
                incident             = incident,
                UnifiedGroupNickName = unifiedGroup.MailNickname,
                UnifiedGroupId       = unifiedGroup.Id,
                UnifiedGroupEmail    = unifiedGroup.Mail,
                inspection           = inspection,
                videos = videos,
                files  = groupFiles
                         .Select(i => HyperLink.Create(i.name, i.webUrl, i.id))
                         .ToArray(),
                recentDocuments = recentDocuments
                                  .Select(i => HyperLink.Create(i.name, i.webUrl, i.id))
                                  .ToArray(),
                members = groupMembers,
                roomInspectionPhotos = getInspectionPhotos,
                inspectionComment    = await GetInspectionCommentAsync(inspectionID, incident.sl_roomID.Id),
                tasks                 = tasks.ToArray(),
                repairPeople          = getRepairPeople != null ? getRepairPeople : new Graph.User[0],
                repairPhotos          = getRepairPhotos != null ? await getRepairPhotos : new RepairPhoto[0],
                DispatcherMails       = isCurrentUserDispatcher ? await GetMailsForDispatcherAsync(graphService, CurrentUser) : new HyperLink[0],
                oneNotePages          = oneNotePages,
                oneNoteUrl            = notebook != null ? notebook.oneNoteWebUrl: "",
                conversations         = groupConversations,
                PlanId                = plan != null ? plan.id : string.Empty,
                PropertyExcelWorkbook = propertyExcelWorkbook,
                bAnnotateImage        = bannotateImage
            };

            return(viewModel);
        }
        public async Task<Event> ScheduleRepair(DashboardInspectionDetailsViewModel model)
        {
            DateTime repairDate = DateTime.Parse(model.timeSlotsSelectedValue);
            ScheduleRepairUpdate updateJson = new ScheduleRepairUpdate();
            updateJson.sl_dispatcherComments = model.dispatcherComments;
            updateJson.sl_repairScheduled = repairDate.ToUniversalTime();
            updateJson.sl_repairPerson = model.repairPeopleSelectedValue;
            updateJson.__metadata = new metadata { type = "SP.Data.IncidentsListItem" };
            await SuiteLevelWebApp.Utils.RestHelper.PostRestDataToDemoSite("/_api/lists/GetByTitle('Incidents')/Items(" + model.incidentId + ")", JsonConvert.SerializeObject(updateJson), _token);

            var incident = await GetIncidentById(model.incidentId);
            var repairPeople = await GetRepairPeopleByEmailAddress(model.repairPeopleSelectedValue);

            //create a new event 
            Attendee attendee = new Attendee
            {
                EmailAddress = new EmailAddress
                {
                    Address = repairPeople.sl_emailaddress,
                    Name = repairPeople.Title
                },
                Type = AttendeeType.Required
            };

            Attendee[] attendees = new Attendee[1];
            attendees[0] = attendee;

            Event newEvent = new Event
            {
                Subject = "Repair Event",
                Body = new ItemBody
                {
                    Content = incident.sl_dispatcherComments,
                    ContentType = BodyType.HTML
                },
                ShowAs = FreeBusyStatus.Busy,
                Start = repairDate.ToUniversalTime(),
                End = (repairDate.AddHours(1)).ToUniversalTime(),
                Location =  new Location
                {
                    DisplayName = incident.sl_roomID.Title
                },
                Attendees = attendees
            };

            return newEvent;
        }
        public async Task<DashboardInspectionDetailsViewModel> GetDashboardInspectionDetailsViewModelAsync(Graph.GraphService graphService, OneNoteServiceFactory oneNoteServiceFactory, int incidentId, string CurrentUser)
        {
            Task<Graph.IUser[]> getRepairPeople = null;
            Task<RepairPhoto[]> getRepairPhotos = null;

            var videos = GetVideosAsync(AppSettings.VideoPortalIncidentsChannelName, incidentId);

            var incident = await GetIncidentByIdAsync(incidentId);
            if (incident.sl_inspectionIDId == null) return null;

            var property = incident.sl_propertyID;
            var propertyImgUrl = GetPropertyPhotoAsync(property.Id);

            var inspectionID = incident.sl_inspectionIDId.Value;
            var inspection = GetInspectionByIdAsync(inspectionID);
            var getInspectionPhotos = GetInspectionPhotosAsync(inspectionID);

            var incidentStatus = incident.sl_status;
            if (incidentStatus == "Pending Assignment")
                getRepairPeople = graphService.GetGroupMembersAsync("Repair People");
            if (incidentStatus == "Repair Pending Approval" || incidentStatus == "Repair Approved")
                getRepairPhotos = GetRepairPhotosAsync(incidentId);

            var unifiedGroupFetcher = graphService.groups.GetById(property.sl_group);
            var unifiedGroup = unifiedGroupFetcher.ExecuteAsync();
            var groupFiles = GetGroupFilesAsync(unifiedGroupFetcher, (await unifiedGroup).mailNickname);
            var groupConversations = GetConversationsAsync(unifiedGroupFetcher, (await unifiedGroup).mail);

            var notebookName = (await unifiedGroup).displayName + " Notebook"; ;
            var oneNoteService = oneNoteServiceFactory.CreateOneNoteServiceForUnifiedGroup(await unifiedGroup);
            var notebook = GetOrCreateNoteBook(await oneNoteService, notebookName);
            var pages = (await notebook) != null
                ? GetOneNotePagesAsync(await oneNoteService, (await notebook).Id, property.Title, incidentId)
                : Task.FromResult(new HyperLink[0]);

            // Repair people are included in property group.
            // Before we get members of a group, we must make sure that repair people have been retrieved.
            // Otherwise, we'll get an error: 
            //         The context is already tracking a different entity with the same resource Uri.
            if (getRepairPeople != null) await getRepairPeople;
            var groupMembers = graphService.GetGroupMembersAsync(unifiedGroupFetcher);

            var recentEarliestDateTime = new DateTimeOffset(DateTime.UtcNow).AddDays(-7);
            var recentDocuments = (await groupFiles)
                .Where(i => i.dateTimeLastModified > recentEarliestDateTime)
                .ToList();

            property.propertyImgUrl = await propertyImgUrl;

            var isCurrentUserDispatcher = CurrentUser == AppSettings.DispatcherEmail;


            var viewModel = new DashboardInspectionDetailsViewModel
            {
                viewName = IncidentStatusViewMappings[incidentStatus],
                PropertyDetail = property,
                incidentId = incidentId,
                incident = incident,
                UnifiedGroupNickName = (await unifiedGroup).mailNickname,
                UnifiedGroupId = (await unifiedGroup).objectId,
                UnifiedGroupEmail = (await unifiedGroup).mail,
                inspection = await inspection,
                videos = await videos,
                files = (await groupFiles)
                    .Select(i => HyperLink.Create(i.name, i.webUrl))
                    .ToArray(),
                recentDocuments = recentDocuments
                    .Select(i => HyperLink.Create(i.name, i.webUrl))
                    .ToArray(),
                members = await groupMembers,
                roomInspectionPhotos = await getInspectionPhotos,
                inspectionComment = await GetInspectionCommentAsync(inspectionID, incident.sl_roomID.Id),
                //tasks = await GetTaskHyperLinksAsync(unifiedGroup)
                repairPeople = getRepairPeople != null ? await getRepairPeople : new Graph.IUser[0],
                repairPhotos = getRepairPhotos != null ? await getRepairPhotos : new RepairPhoto[0],
                DispatcherMails = isCurrentUserDispatcher ? await GetMailsForDispatcherAsync(graphService, CurrentUser) : new HyperLink[0],
                oneNoteUrl = (await notebook) != null ? (await notebook).Url : "",
                oneNotePages = await pages,
                conversations = await groupConversations
            };
            return viewModel;
        }
        public async Task<DashboardInspectionDetailsViewModel> GetDashboardInspectionDetailsViewModelAsync(GraphServiceClient graphService, int incidentId, string CurrentUser)
        {
            Graph.User[] getRepairPeople = null;
            Task<RepairPhoto[]> getRepairPhotos = null;

            var videos = await GetVideosAsync(AppSettings.VideoPortalIncidentsChannelName, incidentId);

            var incident = await GetIncidentByIdAsync(incidentId);
            if (incident.sl_inspectionIDId == null) return null;

            var property = incident.sl_propertyID;
            var propertyImgUrl = GetPropertyPhotoAsync(property.Id);

            var inspectionID = incident.sl_inspectionIDId.Value;
            var inspection = await GetInspectionByIdAsync(inspectionID);
            var getInspectionPhotos = await GetInspectionPhotosAsync(inspectionID);

            var incidentStatus = incident.sl_status;
            if (incidentStatus == "Pending Assignment")
            {
                getRepairPeople = await graphService.GetGroupMembersAsync("Repair People");
            }
                

            if (incidentStatus == "Repair Pending Approval" || incidentStatus == "Repair Approved")
                getRepairPhotos = GetRepairPhotosAsync(incidentId);

            var unifiedGroupFetcher = graphService.Groups[property.sl_group];
            var unifiedGroup = await unifiedGroupFetcher.Request().GetAsync();
            var groupFiles = await GetGroupFilesAsync(unifiedGroupFetcher);
            var groupConversations = await GetConversationsAsync(unifiedGroupFetcher, unifiedGroup.Mail);
            var propertyExcelWorkbook = await ExcelService.GetPropertyExcelWorkbooksAsync(property.sl_group);

            var notebook = await OneNoteService.GetNoteBookByNameAsync(unifiedGroup, unifiedGroup.DisplayName + " Notebook");
            var oneNotePages = (notebook != null)
                ? await Services.OneNoteService.GetOneNotePagesAsync(graphService, unifiedGroup)
                : await Task.FromResult(new HyperLink[0]);

            var groupMembers = await graphService.GetGroupMembersAsync(unifiedGroupFetcher);

            var plan = await PlanService.GetPlanAsync(unifiedGroup);
            List<O365Task> tasks = new List<O365Task>();
            if (plan != null)
            {
                tasks = await GetO365TasksAsync(graphService, plan);
            }

            var recentEarliestDateTime = new DateTimeOffset(DateTime.UtcNow).AddDays(-7);
            var recentDocuments = groupFiles
                .Where(i => i.dateTimeLastModified > recentEarliestDateTime)
                .ToList();

            property.propertyImgUrl = await propertyImgUrl;

            var isCurrentUserDispatcher = CurrentUser == AppSettings.DispatcherEmail;

            var bannotateImage = true;
            if (notebook == null || string.IsNullOrEmpty(notebook.oneNoteWebUrl)||
                oneNotePages.Where(x => x.Title.ToString().Equals(string.Format("Incident[{0}]", incidentId))).Count() > 0)
            {
                bannotateImage = false;
            }
            var viewModel = new DashboardInspectionDetailsViewModel
            {
                viewName = IncidentStatusViewMappings[incidentStatus],
                PropertyDetail = property,
                incidentId = incidentId,
                incident = incident,
                UnifiedGroupNickName = unifiedGroup.MailNickname,
                UnifiedGroupId = unifiedGroup.Id,
                UnifiedGroupEmail = unifiedGroup.Mail,
                inspection = inspection,
                videos = videos,
                files = groupFiles
                    .Select(i => HyperLink.Create(i.name, i.webUrl, i.id))
                    .ToArray(),
                recentDocuments = recentDocuments
                    .Select(i => HyperLink.Create(i.name, i.webUrl, i.id))
                    .ToArray(),
                members = groupMembers,
                roomInspectionPhotos = getInspectionPhotos,
                inspectionComment = await GetInspectionCommentAsync(inspectionID, incident.sl_roomID.Id),
                tasks = tasks.ToArray(),
                repairPeople = getRepairPeople != null ? getRepairPeople : new Graph.User[0],
                repairPhotos = getRepairPhotos != null ? await getRepairPhotos : new RepairPhoto[0],
                DispatcherMails = isCurrentUserDispatcher ? await GetMailsForDispatcherAsync(graphService, CurrentUser) : new HyperLink[0],
                oneNotePages = oneNotePages,
                oneNoteUrl = notebook != null ? notebook.oneNoteWebUrl: "",
                conversations = groupConversations,
                PlanId = plan != null ? plan.id : string.Empty,
                PropertyExcelWorkbook =  propertyExcelWorkbook,
                bAnnotateImage = bannotateImage
            };
            return viewModel;
        }