public async Task CreateVehicle_NewVehicleRequest_ReturnStatusCodeOK()
        {
            // Arrange
            var vehicleId = 2;

            var vehicleRequest = new VehicleRequest
            {
                VehicleId   = vehicleId,
                Number      = "A-002",
                Model       = "Honda Civic",
                Description = "Red Color"
            };

            var vehicleResponse = new VehicleResponse
            {
                Id          = Guid.NewGuid(),
                VehicleId   = vehicleId,
                Number      = "A-002",
                Model       = "Honda Civic",
                Description = "Red Color"
            };

            vehiclesService.VehicleExistsAsync(Arg.Any <int>()).Returns(false);
            vehiclesService.AddVehicleAsync(Arg.Any <VehicleRequest>()).Returns(Task.FromResult(vehicleResponse));
            vehiclesService.GetVehicleAsync(vehicleId).Returns(Task.FromResult(vehicleResponse));

            // Act
            var actionResult = await vehiclesController.CreateVehicle(vehicleRequest);

            // Assert
            var requestResult = Assert.IsType <OkObjectResult>(actionResult);

            Assert.Equal((int)System.Net.HttpStatusCode.OK, requestResult.StatusCode);
        }
        public async Task <IActionResult> CreateVehicle([FromBody] VehicleRequest request)
        {
            if (request == null)
            {
                return(BadRequest(ModelState));
            }

            var vehicleExists = await vehiclesService.VehicleExistsAsync(request.VehicleId);

            if (vehicleExists)
            {
                ModelState.AddModelError("", "Vehicle id exists");
                return(StatusCode(404, ModelState));
            }

            var response = await vehiclesService.AddVehicleAsync(request);

            return(Ok(response));
        }