Ejemplo n.º 1
0
        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()));
        }
Ejemplo n.º 4
0
 //  auction/damaged
 public IActionResult Damaged()
 {
     Cars = CarData.GetAll();
     return(View());
 }
Ejemplo n.º 5
0
        public IActionResult Index()
        {
            var model = _db.GetAll();

            return(View(model));
        }