public IActionResult Index() { var model = new Car(); var allCar = _carData.GetAll(); model.brand = _carData.Get(3).brand; return(View(model)); }
public ActionResult Menu() { //PREVENTING DEADLOCK // trick to prevent deadlocks of calling async method // and waiting for on a sync UI thread. var syncContext = SynchronizationContext.Current; SynchronizationContext.SetSynchronizationContext(null); // this is the async call, wait for the result (!) var results = db.GetAll().Result; IEnumerable <MenuViewModel> menuViewModels = results.Select(vm => vm.ToMenuViewModel()).ToList(); // restore the context SynchronizationContext.SetSynchronizationContext(syncContext); return(PartialView("_Navigation", menuViewModels)); }
public async Task <ActionResult> Index([Form] TableQueryOptions queryOptions, string searchString) { ViewBag.QueryOptions = queryOptions; var start = QueryOptionsCalculator.CalculateStartPage(queryOptions); var model = await db.GetAll(); ViewBag.NumberOfEntries = model.Count(); var viewModels = model.Select(m => m.ToViewModel()); if (!String.IsNullOrEmpty(searchString)) { searchString = searchString.ToUpper(); viewModels = viewModels.Where(c => c.CarModel.ToUpper().Contains(searchString) || c.CarProducer.ToUpper().Contains(searchString) || c.CarProductionYear.ToString().Contains(searchString) || c.LpgInstallationModel.ToUpper().Contains(searchString) || c.LpgInstallationProducer.ToUpper().Contains(searchString)); } queryOptions.TotalPages = QueryOptionsCalculator.CalculateTotalPages(viewModels.Count(), queryOptions.PageSize); return(View(viewModels.OrderBy(queryOptions.Sort).Skip(start).Take(queryOptions.PageSize).ToList())); }
// auction/damaged public IActionResult Damaged() { Cars = CarData.GetAll(); return(View()); }
public IActionResult Index() { var model = _db.GetAll(); return(View(model)); }