public async Task <ActionResult> MessagesCenter()
        {
            #region thong tin user
            //ApplicationUser currentUser = await UserManager.FindByIdAsync(User.Identity.GetUserId());
            UserLoginDTO currentUser = await(from userlog in db.UserLogins
                                             where userlog.UserNameCopy == User.Identity.Name
                                             select new UserLoginDTO
            {
                Id             = userlog.Id,
                CharacterLimit = userlog.CharacterLimit,
                FullName       = userlog.FullName,
                AvataImage     = userlog.AvataImage,
                AvataCover     = userlog.AvataCover,
                BrokerVIP      = userlog.BrokerVIP
            }).FirstOrDefaultAsync();
            ViewBag.AvataEmage    = string.IsNullOrEmpty(currentUser.AvataImage) == true ? AppHelper.ImageURLAvataDefault : "/images/avatar/" + currentUser.AvataImage;
            ViewBag.CoverImage    = string.IsNullOrEmpty(currentUser.AvataCover) == true ? AppHelper.ImageURLCoverDefault : "/images/cover/" + currentUser.AvataCover;
            ViewBag.AvataImageUrl = string.IsNullOrEmpty(currentUser.AvataImage) == true ? AppHelper.ImageURLAvataDefault : AppHelper.ImageURLAvata + currentUser.AvataImage;
            ViewBag.CureentUserId = currentUser.Id;
            ViewBag.UserName      = User.Identity.Name;
            @ViewBag.FullName     = currentUser.FullName;
            #endregion

            #region thong tin co phieu ben phai
            var listStock = await(from followStock in db.FollowStocks
                                  orderby followStock.StockFollowed ascending
                                  where followStock.UserId == currentUser.Id
                                  select followStock.StockFollowed
                                  ).ToListAsync();
            //ViewBag.listStockFollow = listStock as List<string>; // client
            #region gia cổ phieu cua cac ma dang theo doi
            ViewBag.listStockPriceFollow = _stockRealtime.GetAllStocksList(listStock as List <string>).Result;
            #endregion
            #region gia chi so index va hnxindex
            var listIndex = new List <string>();
            listIndex.Add("VNINDEX");
            listIndex.Add("HNXINDEX");
            ViewBag.ListIndex = _stockRealtime.GetAllStocksList(listIndex).Result;
            #endregion
            #region reset lai so luong tin nhan
            ViewBag.NewMessege = 0;
            // luu database

            //
            #endregion

            #endregion
            #region Set Info of hot stock
            ViewBag.ListStockHot = AppHelper.GetListHotStock();
            #endregion

            return(View(currentUser));
        }
        public async Task <ActionResult> Index()
        {
            #region get user info
            ViewBag.AbsolutePathHostName = AppHelper.AbsolutePathHostName;
            var company = new StockCode();
            //ApplicationUser currentUser = await UserManager.FindByIdAsync(User.Identity.GetUserId());
            UserLoginDTO currentUser = await(from userlog in db.UserLogins
                                             where userlog.UserNameCopy == User.Identity.Name
                                             select new UserLoginDTO
            {
                Id             = userlog.Id,
                CharacterLimit = userlog.CharacterLimit,
                FullName       = userlog.FullName,
                AvataImage     = userlog.AvataImage,
                AvataCover     = userlog.AvataCover,
                BrokerVIP      = userlog.BrokerVIP
            }).FirstOrDefaultAsync();
            #endregion
            #region Thong tin menu ben trai
            //Thong tin menu ben trai
            var post = await db.Posts.CountAsync(p => p.PostedBy == currentUser.Id);

            var follow = await db.FollowUsers.CountAsync(f => f.UserId == currentUser.Id);

            var follower = await db.FollowUsers.CountAsync(f => f.UserIdFollowed == currentUser.Id);

            ViewBag.TotalPost = post;
            ViewBag.Follow    = follow;
            ViewBag.Follower  = follower;

            ViewBag.CureentUserId  = currentUser.Id;
            ViewBag.CharacterLimit = currentUser.CharacterLimit;
            ViewBag.UserName       = User.Identity.Name;
            ViewBag.FullName       = currentUser.FullName;
            ViewBag.AvataEmage     = string.IsNullOrEmpty(currentUser.AvataImage) == true ? AppHelper.ImageURLAvataDefault : AppHelper.ImageURLAvata + currentUser.AvataImage;
            ViewBag.CoverImage     = string.IsNullOrEmpty(currentUser.AvataCover) == true ? AppHelper.ImageURLCoverDefault : AppHelper.ImageURLCover + currentUser.AvataCover;


            // cac post duoc loc tu danh muc nguoi theo doi => dc load o duoi client san
            var listPersonFollow = await(from userFollow in db.FollowUsers
                                         where userFollow.UserId == currentUser.Id
                                         select userFollow.UserIdFollowed
                                         ).ToArrayAsync();

            ViewBag.ListFollow = listPersonFollow as int[]; //client

            // cac post dc loc tu danh muc dau tu => dc load o duoc client san
            var listStock = await(from followStock in db.FollowStocks
                                  orderby followStock.StockFollowed ascending
                                  where followStock.UserId == currentUser.Id
                                  select followStock.StockFollowed).ToListAsync();

            ViewBag.listStockFollow = listStock as List <string>; // load o cliet
            // End thong tin menu ben trai
            //so luong tin cua User
            var numberMessegeNew = db.NotificationMesseges.Where(nm => nm.UserReciver == currentUser.Id && nm.NumNoti > 0).Sum(mn => mn.NumNoti);
            ViewBag.NewMessege = numberMessegeNew;


            #endregion
            #region danh muc co phieu dang follow
            ViewBag.listStockPriceFollow = _stockRealtime.GetAllStocksList(listStock as List <string>).Result;
            #endregion

            #region gia chi so index va hnxindex
            var listIndex = new List <string>();
            listIndex.Add("VNINDEX");
            listIndex.Add("HNXINDEX");
            ViewBag.ListIndex = _stockRealtime.GetAllStocksList(listIndex).Result;
            #endregion

            #region Set Info of hot stock
            ViewBag.ListStockHot = AppHelper.GetListHotStock();
            #endregion

            return(View(currentUser));
        }