Exemplo n.º 1
0
        public async Task AddOrUpdateCar(AddOrUpdateCarInput input)
        {
            if (input.Id.HasValue)
            {
                var car = await _repository.GetAsync(input.Id.Value);

                if (car == null)
                {
                    throw new Exception($"No Car was found with Id of {input.Id}");
                }

                car.BodyType       = input.BodyType;
                car.Make           = input.Make;
                car.Engine         = input.Engine;
                car.Model          = input.Model;
                car.NumberOfDoors  = input.NumberOfDoors;
                car.NumberOfWheels = input.NumberOfWheels;

                await _repository.UpdateAsync(car);
            }
            else
            {
                var car = new Car()
                {
                    BodyType       = input.BodyType,
                    Make           = input.Make,
                    Engine         = input.Engine,
                    Model          = input.Model,
                    NumberOfDoors  = input.NumberOfDoors,
                    NumberOfWheels = input.NumberOfWheels
                };

                await _repository.InsertAsync(car);
            }
        }
Exemplo n.º 2
0
 public async Task AddOrUpdate(AddOrUpdateCarInput input)
 {
     await _carService.AddOrUpdateCar(input);
 }