private AttractionTypeService CreateAttractionTypeService() { var userID = Guid.Parse(User.Identity.GetUserId()); var service = new AttractionTypeService(userID); return(service); }
// GET: AttractionType public ActionResult Index(string sortOrder, string currentFilter, string searchString, int?page) { ViewBag.CurrentSort = sortOrder; ViewBag.NameSortParm = String.IsNullOrEmpty(sortOrder) ? "name_desc" : ""; if (searchString != null) { page = 1; } else { searchString = currentFilter; } ViewBag.CurrentFilter = searchString; var userID = Guid.Parse(User.Identity.GetUserId()); var service = new AttractionTypeService(userID); var attractionTypes = service.GetAttractionTypes(); if (!String.IsNullOrEmpty(searchString)) { attractionTypes = attractionTypes.Where(t => t.AttractionTypeName.ToLower().Contains(searchString.ToLower())); } switch (sortOrder) { case "name_desc": attractionTypes = attractionTypes.OrderByDescending(t => t.AttractionTypeName); break; default: attractionTypes = attractionTypes.OrderBy(t => t.AttractionTypeName); break; } int pageSize = 8; int pageNumber = (page ?? 1); return(View(attractionTypes.ToPagedList(pageNumber, pageSize))); }