コード例 #1
0
        /// <summary>
        /// Search Top 3 Profile by Key | Content of Post
        /// </summary>
        /// <param name="textSearch"></param>
        /// <returns></returns>
        public IActionResult SearchTop3ProfileByKey(string textSearch)
        {
            var data = ProfileProcess.SearchProfileByKey(textSearch);
            List <ProfileModel> listProfile = new List <ProfileModel>();

            foreach (var item in data)
            {
                listProfile.Add(new ProfileModel
                {
                    ProfileID    = item.ProfileID,
                    AccountID    = item.AccountID,
                    ProfileName  = item.ProfileName,
                    Bio          = item.Bio,
                    Email        = item.Email,
                    Phone        = item.Phone,
                    Gender       = item.Gender,
                    DateOfBirth  = item.DateOfBirth,
                    ProfilePhoto = item.ProfilePhoto,
                    Follower     = item.Follower,
                    Following    = item.Following,
                    NoOfPosts    = item.NoOfPosts
                });
            }
            return(View(listProfile));
        }
コード例 #2
0
        public IActionResult SearchByKey(string textSearch)
        {
            ViewData["textSearch"] = textSearch;
            var dataProfile = ProfileProcess.SearchProfileByKey(textSearch);
            List <ProfileModel> listProfile = new List <ProfileModel>();

            foreach (var item in dataProfile)
            {
                listProfile.Add(new ProfileModel
                {
                    ProfileID    = item.ProfileID,
                    AccountID    = item.AccountID,
                    ProfileName  = item.ProfileName,
                    Bio          = item.Bio,
                    Email        = item.Email,
                    Phone        = item.Phone,
                    Gender       = item.Gender,
                    DateOfBirth  = item.DateOfBirth,
                    ProfilePhoto = item.ProfilePhoto,
                    Follower     = item.Follower,
                    Following    = item.Following,
                    NoOfPosts    = item.NoOfPosts
                });
            }
            ViewData["ListProfile"] = listProfile;

            var data = PostProcess.SearchPostByKey(textSearch);
            List <PostModel> listPost = new List <PostModel>();

            foreach (var item in data)
            {
                listPost.Add(new PostModel
                {
                    PostID       = item.PostID,
                    ProfileID    = item.ProfileID,
                    PostContent  = item.PostContent,
                    PostDate     = item.PostDate,
                    NoOfCmts     = item.NoOfCmts,
                    NoOfLikes    = item.NoOfLikes,
                    ProfileName  = item.ProfileName,
                    ProfileImage = item.ProfileImage
                });
            }
            ViewData["ListPost"] = listPost;
            // truyen qua viewBag |  View Data
            return(View());
        }