public IActionResult CreateTrack() { ViewBag.EquipmentTrackSuccess = HttpContext.Session.GetString("EquipmentTrackSuccess"); TrackEditViewModel cu = new TrackEditViewModel() { job = new SelectList(ServiceRequestImp.GetRequest(), "Id", "RequestName"), Team = new SelectList(TeamRepository.GetAll(), "Id", "name"), Equip = new SelectList(EquipmentRepository.GetAll(), "Id", "EquipmentName") }; return(View(cu)); }
public IActionResult ViewEquipment(string sortOrder, string SearchString, string currentFilter, int?page) { ViewData["CurrentSort"] = sortOrder; ViewData["NameSortParm"] = String.IsNullOrEmpty(sortOrder) ? "name_desc" : ""; ViewData["DateSortParm"] = sortOrder == "Date" ? "date_desc" : "Date"; if (SearchString != null) { page = 1; } else { SearchString = currentFilter; } ViewData["CurrentFilter"] = SearchString; var kp = EquipmentRepository.GetAll(); var equipment = from s in kp select s; if (!string.IsNullOrEmpty(SearchString)) { equipment = equipment.Where(s => s.EquipmentName.Contains(SearchString) || s.EquipmentDate.ToString().Contains(SearchString)); } switch (sortOrder) { case "name_desc": equipment = equipment.OrderByDescending(s => s.EquipmentName); break; case "Date": equipment = equipment.OrderBy(s => s.EquipmentDate); break; case "date_desc": equipment = equipment.OrderByDescending(s => s.EquipmentDate); break; default: equipment = equipment.OrderBy(s => s.EquipmentName); break; } int pageSize = 3; return(View(PaginatedList <Equipment> .CreateAsync(equipment, page ?? 1, pageSize))); }