//[Route("~/")]
        //[Route("")]
        public ActionResult Index()
        {
            List<ArticleModel> articles = new List<ArticleModel>();
            user = (Users)Session["User"];
            // if (ModelState.IsValid)
            // {
            ConnManager connManager = new ConnManager();
            if(user!= null && user.UserId == 1)
                articles = connManager.GetArticles("Select * from VwArticles order by articleId desc");
            else
                articles = connManager.GetArticles("Select * from VwArticles where IsDisplay =1 order by articleId desc");

            // }

            PagingInfo info = new PagingInfo();
            info.SortField = " ";
            info.SortDirection = " ";
            info.PageSize = 7;
            info.PageCount = Convert.ToInt32(Math.Ceiling((double)(articles.Count/info.PageSize)));
            info.CurrentPageIndex = 0;

            // var query = articles.OrderByDescending(c => c.ArticleID).Take(info.PageSize);

            var query = articles.AsQueryable();
            query = query.Skip(info.CurrentPageIndex * info.PageSize).Take(info.PageSize);
            ViewBag.PagingInfo = info;

            return View(query.ToList());
        }
        public ActionResult LogOut()
        {
            Session["User"] = null;
            Session["Facebook"] = null;
            Session.RemoveAll();
            List<ArticleModel> articles = new List<ArticleModel>();
            ConnManager connManager = new ConnManager();
            articles = connManager.GetArticles("Select * from VwArticles where articleid not in (10044,10045,10046,10047,10048,10049) order by articleId desc");
            connManager.DisposeConn();

            PagingInfo info = new PagingInfo();
            info.SortField = " ";
            info.SortDirection = " ";
            info.PageSize = 10;
            info.PageCount = Convert.ToInt32(Math.Ceiling((double)(articles.Count / info.PageSize)));
            info.CurrentPageIndex = 0;
            var query = articles.OrderBy(c => c.ArticleID).Take(info.PageSize);
            ViewBag.PagingInfo = info;
            ViewBag.UserEmail = null;

            Response.Redirect("../Articles/Index");

            return View("../Articles/Index", articles);
        }
        public ActionResult Index(PagingInfo info)
        {
            List<ArticleModel> articles = new List<ArticleModel>();
            if (ModelState.IsValid)
            {
                ConnManager connManager = new ConnManager();
                user = (Users)Session["User"];
                if (user != null && user.UserId == 1)
                    articles = connManager.GetArticles("Select * from VwArticles order by articleId desc");
                else
                    articles = connManager.GetArticles("Select * from VwArticles where IsDisplay =1 order by articleId desc");

            }

            IQueryable<ArticleModel> query = articles.AsQueryable();
            query = query.Skip(info.CurrentPageIndex * info.PageSize).Take(info.PageSize);
            ViewBag.PagingInfo = info;
            List<ArticleModel> model = query.ToList();
            return View(model);
        }
        public ActionResult MyQues(PagingInfo info)
        {
            if (Request.Form["Cancel"] == null)
            {
                List<QuestionModel> questions = new List<QuestionModel>();
                questions = GetMyQues(questions);

                IQueryable<QuestionModel> query = questions.AsQueryable();
                query = query.Skip(info.CurrentPageIndex * info.PageSize).Take(info.PageSize);
                ViewBag.PagingInfo = info;
                List<QuestionModel> model = query.ToList();
                return View(model);
            }
            else
            {
                if (Session["User"] != null)
                {
                    user = (Users)Session["User"];
                }
                return View("../Account/ViewUser", user);

            }
        }
 public ActionResult MyQues()
 {
     List<QuestionModel> questions = new List<QuestionModel>();
     questions = GetMyQues(questions);
     PagingInfo info = new PagingInfo();
     info.SortField = " ";
     info.SortDirection = " ";
     info.PageSize = 20;
     info.PageCount = Convert.ToInt32(Math.Ceiling((double)(questions.Count() / info.PageSize)));
     info.CurrentPageIndex = 0;
     var query = questions.OrderBy(c => c.QuestionID).Take(info.PageSize);
     ViewBag.PagingInfo = info;
     return View(query.ToList());
 }