Esempio n. 1
0
        public async Task <CarBrandModel> AddAsync(CarBrandModel model)
        {
            var entity = MapFromModel(model);
            var result = await _carBrandRepository.AddAsync(entity);

            return(MapToModel <CarBrandModel>(result));
        }
Esempio n. 2
0
        public async Task <ActionResult> CreateCar([FromBody] CreateCarDto createCarDto)
        {
            var car = _mapper.Map <Car>(createCarDto);
            await _carRepository.AddAsync(car);

            await _carRepository.Context.SaveChangesAsync();

            var carColor = new CarColor(car.Key, createCarDto.ColorId);
            await _carColorRepository.AddAsync(carColor);

            var carBrand = new CarBrand(car.Key, createCarDto.CarBrandId);
            await _carBrandRepository.AddAsync(carBrand);

            await _carColorRepository.Context.SaveChangesAsync();

            return(Ok());
        }