public async Task <ActionResult <CarModelDTO> > CreateCarModelAsync(CarModelCreate data)
        {
            try
            {
                var res = await carModelService.CreateCarModelAsync(data);

                return(Ok(res));
            }
            catch
            {
                return(StatusCode(500, "Internal server error"));
            }
        }
        public async Task <CarModelDTO> CreateCarModelAsync(CarModelCreate data)
        {
            var model = new CarModel
            {
                Name           = data.Name,
                Year           = data.Year,
                ManufacturerId = data.ManufacturerId
            };

            _db.CarModels.Add(model);
            var saved = await _db.SaveChangesAsync();

            if (saved <= 0)
            {
                throw new Exception("Problem saving data.");
            }

            return(MapToDTO(model));
        }
 public async Task <CarModelDTO> CreateCarModelAsync(CarModelCreate data)
 {
     return(await carModelRepository.CreateCarModelAsync(data));
 }