예제 #1
0
        public async Task <BaseViewModel> GetViewModelAsync()
        {
            var vm = new TabListViewModel
            {
            };

            return(vm);
        }
예제 #2
0
 public IViewComponentResult Invoke(TabListViewModel ViewX)
 {
     if (ViewX.ViewType == (int)ViewType.ThaoLuanGV)
     {
         ViewX.tabCongKhai = ViewX.ListBaiPostThaoLuan.Where(x => x.Loai == (int)BaiPostType.CongKhai);
         ViewX.tabRiengTu  = ViewX.ListBaiPostThaoLuan.Where(x => x.Loai == (int)BaiPostType.RiengTu);
     }
     else
     {
     }
     return(View(ViewX));
 }
        public async Task <ActionResult> ViewAudiance(string id, string tid, string page)
        {
            var announcement = await Cache.Announcements.GetItemAsync(id);

            TabListViewModel audianceInfo = new TabListViewModel();

            audianceInfo.FirstTab.Title = "1:1 Chat";
            audianceInfo.FirstTab.Type  = "personAudiance";

            audianceInfo.SecondTab.Title = "Channels";
            audianceInfo.SecondTab.Type  = "channelAudiance";

            audianceInfo.FirstTab.TenantId = audianceInfo.SecondTab.TenantId = tid;
            audianceInfo.SelectFirstTab    = page == "viewGroupAudiance";
            // Fill in audianceInfo model.
            if (announcement != null)
            {
                var token = await GraphHelper.GetAccessToken(tid, ApplicationSettings.AppId, ApplicationSettings.AppSecret);

                GraphHelper helper = new GraphHelper(token);

                var allUsers = new List <string>();
                foreach (var group in announcement.Recipients.Groups)
                {
                    foreach (var user in group.Users)
                    {
                        if (allUsers.Contains(user.Id))
                        {
                            continue;
                        }
                        else
                        {
                            allUsers.Add(user.Id);
                        }

                        var userDetails = await Cache.Users.GetItemAsync(user.Id);

                        if (userDetails == null)
                        {
                            continue;
                        }
                        var item = GetUserItem(tid, helper, userDetails);
                        audianceInfo.FirstTab.Items.Add(item);
                    }
                }

                foreach (var channel in announcement.Recipients.Channels)
                {
                    var messageId = channel.Channel.MessageId;
                    var team      = await Cache.Teams.GetItemAsync(channel.TeamId);

                    if (team == null)
                    {
                        continue;
                    }

                    var channelDetails = team.Channels.FirstOrDefault(c => c.Id == channel.Channel.Id);
                    if (channelDetails == null)
                    {
                        continue;
                    }

                    audianceInfo.SecondTab.Items.Add(
                        new ViewModels.Item()
                    {
                        Id               = team.Id,
                        ImageUrl         = ApplicationSettings.BaseUrl + "/Resources/Team.png",
                        Title            = channelDetails.Name,
                        SubTitle         = team.Name,
                        EnableLikeButton = false,
                        DeepLinkUrl      =
                            !string.IsNullOrEmpty(messageId) ?
                            "https://teams.microsoft.com/l/message/" + messageId?.Replace(";messageid=", "/")
                             : $"https://teams.microsoft.com/l/channel/{channel.TeamId}/General"
                    });
                }
            }
            return(View("TabListView", audianceInfo));
        }
        public async Task <ActionResult> ViewAnalytics(string id, string tid, string page)
        {
            var announcement = await Cache.Announcements.GetItemAsync(id);

            TabListViewModel analyticsInfo = new TabListViewModel();

            analyticsInfo.FirstTab.Title    = "Acknowledgement";
            analyticsInfo.SecondTab.Title   = "Reaction";
            analyticsInfo.FirstTab.TenantId = analyticsInfo.SecondTab.TenantId = tid;

            analyticsInfo.FirstTab.Type  = "personAcknowledgement";
            analyticsInfo.SecondTab.Type = "personReaction";

            // Fill in analyticsInfo model.
            if (announcement != null)
            {
                var token = await GraphHelper.GetAccessToken(tid, ApplicationSettings.AppId, ApplicationSettings.AppSecret);

                GraphHelper helper = new GraphHelper(token);

                var allAckUsers      = new List <string>();
                var allReactionUsers = new List <string>();
                foreach (var group in announcement.Recipients.Groups)
                {
                    foreach (var user in group.Users)
                    {
                        // Fill in the Item details.
                        var userDetails = await Cache.Users.GetItemAsync(user.Id);

                        if (user.IsAcknoledged)
                        {
                            if (!allAckUsers.Contains(user.Id))
                            {
                                var item = GetUserItem(tid, helper, userDetails);
                                analyticsInfo.FirstTab.Items.Add(item);
                                allAckUsers.Add(user.Id);
                            }
                        }
                        if (user.LikeCount != 0)
                        {
                            if (!allReactionUsers.Contains(user.Id))
                            {
                                var item = GetUserItem(tid, helper, userDetails);
                                item.EnableLikeButton = true;
                                analyticsInfo.SecondTab.Items.Add(item);
                                allReactionUsers.Add(user.Id);
                            }
                        }
                    }
                }
                foreach (var channel in announcement.Recipients.Channels)
                {
                    foreach (var user in channel.LikedUsers)
                    {
                        //var userDetails = await Cache.Users.GetItemAsync(user.Id);
                        var userDetails = await Cache.Users.GetItemAsync(user);

                        if (channel.LikedUsers.Count != 0)
                        {
                            if (!allReactionUsers.Contains(user))
                            {
                                var item = GetUserItem(tid, helper, userDetails);
                                item.EnableLikeButton = true;
                                analyticsInfo.SecondTab.Items.Add(item);
                                allReactionUsers.Add(user);
                            }
                        }
                    }
                }
            }

            analyticsInfo.SelectFirstTab = page == "viewAckAnalytics";
            if (analyticsInfo.SelectFirstTab && analyticsInfo.FirstTab.Items.Count == 0)
            {
                analyticsInfo.SelectFirstTab = false;
            }
            return(View("TabListView", analyticsInfo));
        }