public VehicleTechSpecification MapDtoToVehicleTechSpecification(VehicleTechSpecificationDTO dto)
 {
     return(new VehicleTechSpecification
     {
         Id = new ObjectId(),
         Engine = new Engine
         {
             Id = new ObjectId(),
             EngineCapacity = dto.Engine.EngineCapacity,
             HorsePowers = dto.Engine.HorsePowers,
             Name = dto.Engine.Name,
             Petrol = dto.Engine.Petrol
         },
         GearBox = new GearBox
         {
             Id = new ObjectId(),
             Name = dto.GearBox.Name,
             GearBoxType = dto.GearBox.GearBoxType,
             GearsCount = dto.GearBox.GearsCount
         },
         AdditionalCharacteristics = dto.AdditionalCharacteristics,
         SpareParts = new List <SparePart>(),
     });
 }
예제 #2
0
        public async Task <IActionResult> CreateVehicleTechSpecificationByVehnicleId(string vehicleId, [FromBody] VehicleTechSpecificationDTO vehicleTechSpecificationDTO)
        {
            var createVehicleTechSpecByVehicleIdCommand = new CreateTechSpecificationByVehicleIdCommand(vehicleId, vehicleTechSpecificationDTO);

            logger.Information($"Senidng CreateTechSpecificationByVehicleIdCommand for vehicle with id: {vehicleId} " +
                               $"tech specification: Engine: {vehicleTechSpecificationDTO.Engine.Name} Gearbox {vehicleTechSpecificationDTO.GearBox.Name}");

            var vehicleTechSpecId = await mediator.Send(createVehicleTechSpecByVehicleIdCommand);

            if (vehicleTechSpecId.HasNoValue)
            {
                return(BadRequest($"Cannot create vehicle tech specification for vehicle with id {vehicleId}"));
            }

            return(Ok(vehicleTechSpecId.Value));
        }
 public CreateTechSpecificationByVehicleIdCommand(string vehicleId, VehicleTechSpecificationDTO vehicleTechSpecificationDTO)
 {
     VehicleId = vehicleId;
     VehicleTechSpecificationDTO = vehicleTechSpecificationDTO;
     VehicleTechSpecificationDTO.SpareParts.AddDefaultSpareParts();
 }