Example #1
0
        public async Task GetCarModelByIdTest()
        {
            var car = CarDataSeeder.GetEntities().First();
            await _carRepository.AddAsync(car);

            Assert.NotNull(await _carModelService.GetCarModelByIdAsync(1));
        }
Example #2
0
        public async Task <IActionResult> CarDetails(int id)
        {
            var carModel = await _carModelService.GetCarModelByIdAsync(id);

            if (carModel == null)
            {
                return(NotFound($"Car with {id} not found!"));
            }

            return(View(carModel));
        }
        public async Task <ActionResult <CarModelDTO> > GetCarModelByIdAsync(int id)
        {
            try
            {
                var res = await carModelService.GetCarModelByIdAsync(id);

                return(Ok(res));
            }
            catch
            {
                return(StatusCode(500, "Internal server error"));
            }
        }