public async Task <ProductionLine> PostProductionLine(ProductionLineDTO productionLineDTO) { List <Machine> machines = ValidateMachines(productionLineDTO.Machines).Result; ProductionLine productionLine = new ProductionLine(new ProductionLineDescription(productionLineDTO.description), machines); await _productionLineRepository.Create(productionLine); return(productionLine); }
public async Task <OutProductionLineDTO> CreateProductionLineAsync(InProductionLineDTO inProductionLineDto) { List <Machine> machines = new List <Machine>(); foreach (var machineId in inProductionLineDto.Machines) { machines.Add(await _machineRepository.GetById(machineId)); } var prodLine = ProductionLineMapping.InDTOToProductionLine(inProductionLineDto); prodLine.Machines = machines; var productionLine = await _productionLineRepository.Create(prodLine); var outProductionLine = ProductionLineMapping.ProductionLineToOutDTO(productionLine); return(outProductionLine); }