Example #1
0
        public void AddItem(Vehicle vehicle)
        {
            if (String.IsNullOrWhiteSpace(vehicle?.Id))
            {
                throw new Exception("Id não encontrado!");
            }

            if (vehicle?.Chassi.Length != 17)
            {
                throw new Exception("Chassi incorreto, deverá possuir 17 caracteres");
            }

            var get = _vehicleRepository.FindByIdAsync(vehicle.Chassi);

            if (!String.IsNullOrWhiteSpace(get.Result?.Chassi))
            {
                throw new Exception($"Veículo já existente, não é possível adicionar mesmo chassi {get.Result?.Chassi} duplicado! Dois Veículos são considerados clonados se os seus chassi forem iguais.");
            }

            _vehicleRepository.AddAync(vehicle);
        }