private async Task <StatusCodeResult> ValidateVechile(Vehicle vehicle) { bool existsError = false; if (!Enum.IsDefined(typeof(FuelType), vehicle.FuelType)) { ModelState.AddModelError("", "Este tipo de combustível não existe, para mais informação consute o suporte"); existsError = true; } if (!Enum.IsDefined(typeof(VehicleType), vehicle.VehicleType)) { ModelState.AddModelError("", "Este tipo de veículo não existe, para mais informação consulte o suporte"); existsError = true; } if (!await _makeRepository.ExistsMake(vehicle.MakeId)) { ModelState.AddModelError("", "Esta marca não existe"); existsError = true; } if (!await _modelRepository.ExistsModel(vehicle.ModelId)) { ModelState.AddModelError("", "Este modelo não existe"); existsError = true; } if (!await _userRepository.UserExists(vehicle.ResponsibleUserId)) { ModelState.AddModelError("", "Este usuário não existe"); existsError = true; } return(existsError ? StatusCode(404) : null); }