//[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 Search(string txtArticleTitle)
        {
            string strSQL = "Select * from VwArticles Where ArticleId > 0 ";

            if (!string.IsNullOrEmpty(txtArticleTitle))
            {
                strSQL += " and ArticleTitle like '%" + txtArticleTitle + "%' ";
            }
            strSQL += " order by InsertedDate desc";

            List<ArticleModel> articles = new List<ArticleModel>();
            if (ModelState.IsValid)
            {
                ConnManager connManager = new ConnManager();
                articles = connManager.GetArticles(strSQL);
            }
            return View("../Articles/Index", articles);
            //return View(articles);
        }
 private List<ArticleModel> GetMyArts(List<ArticleModel> solns)
 {
     user = (Users)Session["User"];
     if (ModelState.IsValid)
     {
         string strSQL = string.Empty;
         strSQL = "SELECT * FROM VwArticles WHERE UserId = " + user.UserId;
         ConnManager connManager = new ConnManager();
         solns = connManager.GetArticles(strSQL);
     }
     return solns;
 }