Esempio n. 1
0
        private CarBrandTableViewModel CreateTableViewModel(IEnumerable <CarBrandViewModel> brands, long selectedCarTypeId = 0)
        {
            var carTypes = carTypeService.GetAll().OrderBy(it => it.Name).ToList();

            carTypes.Insert(0, new CarTypeViewModel()
            {
                Id   = 0,
                Name = "All"
            });

            foreach (var type in carTypes)
            {
                if (type.Id == selectedCarTypeId)
                {
                    type.IsSelected = true;
                }
            }

            var countries = countryService.GetAll();

            return(new CarBrandTableViewModel()
            {
                Brands = brands,
                Types = carTypes,
                Countries = countries
            });
        }
Esempio n. 2
0
        public IActionResult GetAll()
        {
            var result = _carTypeService.GetAll();

            if (result.Success)
            {
                return(Ok(result));
            }
            return(BadRequest(result));
        }