Ejemplo n.º 1
0
        //public List<string> _listStock { get; set; }
        public async Task <ActionResult> Index()
        {
            #region [Login User]
            if (User.Identity.IsAuthenticated)// neu dang nhap thi cho ve thẳng myprofile
            {
                return(RedirectToAction("", "myprofile"));
            }

            ViewBag.AbsolutePathHostName = AppHelper.AbsolutePathHostName;
            if (User.Identity.IsAuthenticated)
            {
                ApplicationUser currentUser = await UserManager.FindByIdAsync(User.Identity.GetUserId());

                ViewBag.CureentUserId = currentUser.Id;
                ViewBag.UserName      = currentUser.UserName;

                ViewBag.AvataEmage = string.IsNullOrEmpty(currentUser.UserExtentLogin.AvataImage) == true ? AppHelper.ImageURLAvataDefault : AppHelper.ImageURLAvata + currentUser.UserExtentLogin.AvataImage;
                ViewBag.CoverImage = string.IsNullOrEmpty(currentUser.UserExtentLogin.AvataCover) == true ? AppHelper.ImageURLCoverDefault : AppHelper.ImageURLCover + currentUser.UserExtentLogin.AvataCover;

                // End thong tin menu ben trai
                //so luong tin cua User
                var numberMessegeNew = db.NotificationMesseges.Where(nm => nm.UserReciver == currentUser.UserExtentLogin.Id && nm.NumNoti > 0).Sum(mn => mn.NumNoti);
                ViewBag.NewMessege = numberMessegeNew;
            }
            else
            {
                ViewBag.AvataEmage = AppHelper.ImageURLAvataDefault;
            }
            #endregion

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

            #region random dan phim chuyen nghiep
            var DanPhimRandom = await(from u in db.UserLogins
                                      orderby Guid.NewGuid()
                                      where u.BrokerVIP == true
                                      select new UserRandom
            {
                Avata    = string.IsNullOrEmpty(u.AvataImage) ? AppHelper.ImageURLAvataDefault : AppHelper.ImageURLAvata + u.AvataImage,
                UserName = u.UserNameCopy,
                FullName = u.FullName
            }).Take(5).ToListAsync();
            ViewBag.DanPhimRandom = DanPhimRandom;
            #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

            return(View());
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> Index(long postid)
        {
            using (db = new testEntities())
            {
                if (User.Identity.IsAuthenticated)
                {
                    ApplicationUser currentUser = new ApplicationUser();
                    currentUser = await UserManager.FindByIdAsync(User.Identity.GetUserId());

                    ViewBag.CureentUserId = currentUser.Id;
                    ViewBag.UserName      = currentUser.UserName;
                    ViewBag.AvataEmage    = string.IsNullOrEmpty(currentUser.UserExtentLogin.AvataImage) == true ? AppHelper.ImageURLAvataDefault : AppHelper.ImageURLAvata + currentUser.UserExtentLogin.AvataImage;
                    var numberMessegeNew = await db.NotificationMesseges.Where(nm => nm.UserReciver == currentUser.UserExtentLogin.Id && nm.NumNoti > 0).SumAsync(mn => mn.NumNoti);

                    ViewBag.NewMessege = numberMessegeNew;
                }
                else
                {
                    ViewBag.AvataEmage = AppHelper.ImageURLAvataDefault;
                }

                var post = await db.Posts.FirstOrDefaultAsync(p => p.PostId == postid);

                #region thong tin chi tiet bai viet o client bang viewbag

                ViewBag.Message              = post.Message;
                ViewBag.MessageNonHtml       = AppHelper.StripTagsCharArray(post.Message);
                ViewBag.PostedByName         = post.UserLogin.UserNameCopy;
                ViewBag.PostedByAvatar       = string.IsNullOrEmpty(post.UserLogin.AvataImage) ? AppHelper.ImageURLAvataDefault : AppHelper.ImageURLAvata + post.UserLogin.AvataImage;
                ViewBag.PostedDate           = post.PostedDate;
                ViewBag.PostId               = post.PostId;
                ViewBag.StockPrimary         = post.StockPrimary;
                ViewBag.Stm                  = post.NhanDinh;
                ViewBag.ChartYN              = post.ChartYN;
                ViewBag.PostBy               = post.PostedBy;
                ViewBag.Chart                = post.ChartImageURL;
                ViewBag.SumReply             = post.SumReply;
                ViewBag.SumLike              = post.SumLike;
                ViewBag.BrkVip               = post.UserLogin.BrokerVIP;
                ViewBag.AbsolutePathHostName = AppHelper.AbsolutePathHostName;

                #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

                // end
                return(View());
            }
        }
Ejemplo n.º 3
0
        public async Task <ActionResult> Index()
        {
            using (db = new testEntities())
            {
                if (User.Identity.IsAuthenticated)
                {
                    ApplicationUser currentUser = new ApplicationUser();
                    currentUser = await UserManager.FindByIdAsync(User.Identity.GetUserId());

                    ViewBag.CureentUserId = currentUser.Id;
                    ViewBag.UserName      = currentUser.UserName;
                    ViewBag.AvataEmage    = string.IsNullOrEmpty(currentUser.UserExtentLogin.AvataImage) == true ? AppHelper.ImageURLAvataDefault : AppHelper.ImageURLAvata + currentUser.UserExtentLogin.AvataImage;
                    var numberMessegeNew = await db.NotificationMesseges.Where(nm => nm.UserReciver == currentUser.UserExtentLogin.Id && nm.NumNoti > 0).SumAsync(mn => mn.NumNoti);

                    ViewBag.NewMessege = numberMessegeNew;
                }
                else
                {
                    ViewBag.AvataEmage = AppHelper.ImageURLAvataDefault;
                }

                ViewBag.AbsolutePathHostName = AppHelper.AbsolutePathHostName;
                #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

                // end
                return(View());
            }
        }
Ejemplo n.º 4
0
        //
        // GET: /Search/
        //private const string ImageURLAvataDefault = "/img/avatar2.jpg";
        //private const string ImageURLAvata = "/images/avatar/";
        public async Task <ActionResult> Index(string q)
        {
            #region thong tin user dang nnhap
            ViewBag.SearchString = q;
            if (User.Identity.IsAuthenticated)
            {
                ApplicationUser currentUser = new ApplicationUser();
                currentUser = await UserManager.FindByIdAsync(User.Identity.GetUserId());

                ViewBag.AvataEmage = string.IsNullOrEmpty(currentUser.UserExtentLogin.AvataImage) == true ? AppHelper.ImageURLAvataDefault : AppHelper.ImageURLAvata + currentUser.UserExtentLogin.AvataImage;
                var numberMessegeNew = await db.NotificationMesseges.Where(nm => nm.UserReciver == currentUser.UserExtentLogin.Id && nm.NumNoti > 0).SumAsync(mn => mn.NumNoti);

                ViewBag.NewMessege = numberMessegeNew;
            }
            else
            {
                ViewBag.AvataEmage = AppHelper.ImageURLAvataDefault;
            }

            #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


            if (string.IsNullOrEmpty(q))
            {
                ViewBag.listStockPriceFind = new List <StockRealTime>();
                ViewBag.UserFindList       = new List <UserFollowView>();
                return(View());
            }
            else
            {
                //var search = db.StockCodes.FirstOrDefault(s => s.Code.StartsWith(q.Replace("$", ""))).Code;
                var searstring      = q.RemoveSpecialString();
                var searchStockList = await(from sc in db.StockCodes
                                            where sc.Code.Contains(searstring) &&
                                            (sc.MarketType == 0 || sc.MarketType == 1 || sc.MarketType == 3)
                                            select sc.Code).ToListAsync();
                var searchUser = await(from us in db.UserLogins
                                       where us.UserNameCopy.Contains(searstring) && us.DisableUser != true
                                       select new UserFollowView
                {
                    UserId   = us.Id,
                    UserName = us.UserNameCopy,
                    Status   = us.Status,
                    Avata    = string.IsNullOrEmpty(us.AvataImage) ? AppHelper.ImageURLAvataDefault : AppHelper.ImageURLAvata + us.AvataImage,
                    BrkVip   = us.BrokerVIP
                }).ToListAsync();
                //load gia co phieu tim duoc
                #region gia cổ phieu cua cac ma tim duoc
                ViewBag.listStockPriceFind = _stockRealtime.GetAllStocksList(searchStockList as List <string>).Result;
                #endregion
                // Nguoi dung tim dc
                #region gia cổ phieu cua cac ma tim duoc
                ViewBag.UserFindList = searchUser;
                #endregion
                #region thong bao cho nguoi dung biet la khong tim thay

                ViewBag.NoStockFind = ": " + searchStockList.Count + " Cổ phiếu";

                ViewBag.NoUserFind = ": " + searchUser.Count + " Người dùng";

                #endregion
                return(View());
            }
        }
Ejemplo n.º 5
0
        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));
        }
Ejemplo n.º 6
0
        public async Task <ViewResult> Index(string symbolName)
        {
            //ApplicationUser currentUser = await UserManager.FindByIdAsync(User.Identity.GetUserId());
            ViewBag.AbsolutePathHostName = AppHelper.AbsolutePathHostName;
            #region danh muc co phieu dang follow
            var postNumber = await db.Posts.CountAsync(s => s.StockPrimary.Contains(symbolName));           // so luong bai viet cua cổ phiếu này

            var stockFollowNumber = await db.FollowStocks.CountAsync(sf => sf.StockFollowed == symbolName); // bao nhieu nguoi da theo doi co phieu nay

            ViewBag.PostNumber        = postNumber;
            ViewBag.StockFollowNumber = stockFollowNumber;
            // function follow stock
            if (User.Identity.IsAuthenticated)
            {
                ApplicationUser currentUser = await UserManager.FindByIdAsync(User.Identity.GetUserId());

                var countStockFollowr = await db.FollowStocks.CountAsync(f => f.UserId == currentUser.UserExtentLogin.Id && f.StockFollowed == symbolName);

                if (countStockFollowr == 1) // kiem tra user nay co follow ma nay khong
                {
                    ViewBag.CheckStockExist = "Y";
                }
                else
                {
                    ViewBag.CheckStockExist = "N";
                }
                // so luong tin nhan
                var numberMessegeNew = await db.NotificationMesseges.Where(nm => nm.UserReciver == currentUser.UserExtentLogin.Id && nm.NumNoti > 0).SumAsync(mn => mn.NumNoti);

                ViewBag.NewMessege = numberMessegeNew;
            }

            #endregion

            #region Thong tin menu ben trai
            if (User.Identity.IsAuthenticated) // thong tin user dang nhap
            {
                ApplicationUser currentUser = await UserManager.FindByIdAsync(User.Identity.GetUserId());

                ViewBag.AvataEmage     = string.IsNullOrEmpty(currentUser.UserExtentLogin.AvataImage) == true ? AppHelper.ImageURLAvataDefault : AppHelper.ImageURLAvata + currentUser.UserExtentLogin.AvataImage;
                ViewBag.CureentUserId  = currentUser.UserExtentLogin.Id;
                ViewBag.UserName       = currentUser.UserName;
                ViewBag.CharacterLimit = currentUser.UserExtentLogin.CharacterLimit;
            }
            else
            {
                ViewBag.AvataEmage = AppHelper.ImageURLAvataDefault;
            }


            // End thong tin menu ben trai


            #endregion

            #region thong tin co phieu
            var company = new StockCode();
            company = await db.StockCodes.FirstOrDefaultAsync(m => m.Code.ToUpper() == symbolName.ToUpper());

            ViewBag.StockCode = company == null?StatusSymbol.NF.ToString() : symbolName.ToUpper();

            ViewBag.StockName = company == null?StatusSymbol.NF.ToString() : company.ShortName;

            ViewBag.LongName = company == null?StatusSymbol.NF.ToString() : company.LongName;

            ViewBag.MarketName = company == null?StatusSymbol.NF.ToString() : company.IndexName;

            ViewBag.ImgEx = ".png";
            #endregion

            #region gia co phieu
            StockRealTime stockprice = new StockRealTime();
            stockprice = _stockRealtime.GetStocksByTicker(symbolName).Result;
            if (stockprice == null)
            {
                stockprice           = new StockRealTime();
                stockprice.CompanyID = symbolName;
            }
            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(stockprice));
        }
Ejemplo n.º 7
0
        public async Task <ActionResult> Index(string g)
        {
            ViewBag.AbsolutePathHostName = AppHelper.AbsolutePathHostName;
            #region thong tin user dang nnhap
            if (User.Identity.IsAuthenticated)
            {
                ApplicationUser currentUser = new ApplicationUser();
                currentUser = await UserManager.FindByIdAsync(User.Identity.GetUserId());

                ViewBag.AvataEmage = string.IsNullOrEmpty(currentUser.UserExtentLogin.AvataImage) == true ? AppHelper.ImageURLAvataDefault : AppHelper.ImageURLAvata + currentUser.UserExtentLogin.AvataImage;
                var numberMessegeNew = await db.NotificationMesseges.Where(nm => nm.UserReciver == currentUser.UserExtentLogin.Id && nm.NumNoti > 0).SumAsync(mn => mn.NumNoti);

                ViewBag.NewMessege = numberMessegeNew;
            }
            else
            {
                ViewBag.AvataEmage = AppHelper.ImageURLAvataDefault;
            }

            #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
            //Top Menu
            #region Set Info of hot stock
            var listHotStock = AppHelper.GetListHotStock();
            ViewBag.ListStockHot = listHotStock;
            #endregion


            #region seach ma co phieu

            if (string.IsNullOrEmpty(g))
            {
                ViewBag.listStockGroup = new List <StockCodeColunn>();
            }
            ViewBag.GroupName = g.ToUpper();
            switch (g)
            {
            case "UPCOM":
                await GetUPCOMList();

                break;

            case "HOTSTOCK":
                await GetHOTSTOCKList(listHotStock);

                break;

            case "INDEX":
                GetINDEXList();
                break;

            default:
                await GetNormalStockList(g);

                break;
            }

            return(View());

            #endregion
        }
Ejemplo n.º 8
0
        public async Task <ActionResult> Index(string username)
        {
            #region thong tin user
            ViewBag.AbsolutePathHostName = AppHelper.AbsolutePathHostName;
            var currentUser = await db.UserLogins.FirstOrDefaultAsync(u => u.UserNameCopy == username); //db.UserLogins.FirstOrDefaultAsync(u => u.UserNameCopy == username);

            if (currentUser == null || string.IsNullOrEmpty(username))
            {
                return(RedirectToAction("", "Search", new { q = username }));
            }

            if (User.Identity.IsAuthenticated)
            {
                ApplicationUser userLogin = await UserManager.FindByIdAsync(User.Identity.GetUserId());

                ViewBag.AvataEmage     = string.IsNullOrEmpty(userLogin.UserExtentLogin.AvataImage) == true ? AppHelper.ImageURLAvataDefault : AppHelper.ImageURLAvata + userLogin.UserExtentLogin.AvataImage;
                ViewBag.CureentUserId  = userLogin.UserExtentLogin.Id;
                ViewBag.UserName       = userLogin.UserName;
                ViewBag.AvataImageUrl  = string.IsNullOrEmpty(userLogin.UserExtentLogin.AvataImage) == true ? AppHelper.ImageURLAvataDefault : AppHelper.ImageURLAvata + userLogin.UserExtentLogin.AvataImage;
                ViewBag.CharacterLimit = currentUser.CharacterLimit;
                #region follow user
                if (userLogin.UserExtentLogin.Id == currentUser.Id)
                {
                    ViewBag.CheckUserExist = "E";
                }
                else
                {
                    var checkUser = await db.FollowUsers.CountAsync(f => f.UserId == userLogin.UserExtentLogin.Id && f.UserIdFollowed == currentUser.Id);

                    if (checkUser == 1)
                    {
                        ViewBag.CheckUserExist = "Y";
                    }
                    else
                    {
                        ViewBag.CheckUserExist = "N";
                    }
                }
                // so luong tin nhan
                var numberMessegeNew = await db.NotificationMesseges.Where(nm => nm.UserReciver == userLogin.UserExtentLogin.Id && nm.NumNoti > 0).SumAsync(mn => mn.NumNoti);

                ViewBag.NewMessege = numberMessegeNew;
                #endregion
            }
            else
            {
                ViewBag.AvataEmage = AppHelper.ImageURLAvataDefault;
            }
            ViewBag.CurrentPositionImage = currentUser.CoverPosition;
            ViewBag.UserName             = username;
            ViewBag.AvataImageUrlCurrent = string.IsNullOrEmpty(currentUser.AvataImage) == true ? AppHelper.ImageURLAvataDefault : AppHelper.ImageURLAvata + currentUser.AvataImage;
            ViewBag.CoverImage           = string.IsNullOrEmpty(currentUser.AvataCover) == true ? AppHelper.ImageURLCoverDefault : AppHelper.ImageURLCover + currentUser.AvataCover;
            ViewBag.StatusShare          = currentUser.Status;
            ViewBag.UserId = currentUser.Id;
            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);

            var followStock = await db.FollowStocks.CountAsync(f => f.UserId == currentUser.Id);

            ViewBag.TotalPost   = post;
            ViewBag.Follow      = follow;
            ViewBag.Follower    = follower;
            ViewBag.followStock = followStock;
            #endregion
            #region ViewbagGenerator
            //_dictionaryViewBag = new Dictionary<string, object>();
            //_dictionaryViewBag.Add("User", currentUser.UserNameCopy);
            //ViewbagGenerator();
            #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));
        }