Ejemplo n.º 1
0
        public ActionResult GetComments(int id)
        {
            var repo = new Repository();
            var comments = (from s in repo.GetComments()
                        select s);

            //var comments = (from c in db.tblComments
            //                .Where(d => d.tblTipsId == id)   // supervisor = 2  , coordinator = 5
            //                select c);

            return PartialView("GetComments", comments);
        }
Ejemplo n.º 2
0
        public ViewResult Index(string sortOrder, string currentFilter, string searchString, int? page)
        {
            ViewBag.CurrentSort = sortOrder;
            ViewBag.TitleSortParm = String.IsNullOrEmpty(sortOrder) ? "title_desc" : "";
            ViewBag.DateSortParm = sortOrder == "Date" ? "date_desc" : "Date";

            if (searchString != null)
            {
                page = 1;
            }
            else
            {
                searchString = currentFilter;
            }

            ViewBag.CurrentFilter = searchString;

            var repo = new Repository();

            var tips = (from s in repo.GetTips()
                        select s);

            //var tips = (from s in db.tblTips
            //           .Where(d => d.@group == 2)   // supervisor = 2  , coordinator = 5
            //            select s);

            //Show the query
            //ViewBag.itemType = tips;

            if (!String.IsNullOrEmpty(searchString))
            {
                tips = tips.Where(s => s.title.Contains(searchString)
                                       || s.body.Contains(searchString));
            }
            switch (sortOrder)
            {
                case "title_desc":
                    tips = tips.OrderByDescending(s => s.title);
                    break;
                case "Date":
                    tips = tips.OrderBy(s => s.created);
                    break;
                case "date_desc":
                    tips = tips.OrderByDescending(s => s.created);
                    break;
                default:  // Name ascending
                    tips = tips.OrderBy(s => s.updated);
                    break;
            }

            int pageSize = 10;
            int pageNumber = (page ?? 1);
            var x = tips.Count();

            ViewBag.TotalCount = x.ToString();
            //ViewBag.TotalItemCount = y.ToString();
            return View(tips.ToPagedList(pageNumber, pageSize));

            //return View(tips.ToPagedList(1, pageSize));
        }