예제 #1
0
        public async Task <OutMachineDTO> CreatMachineAsync(InMachineDTO machineDto)
        {
            var newMachine = MachineMapping.InDtoToMachine(machineDto);

            newMachine.MachineType = await _machineTypeRepository.GetById(machineDto.MachineType);

            var machine = await _machineRepository.Create(newMachine);

            var outMachineDto = MachineMapping.MachineToOutDto(machine);

            return(outMachineDto);
        }
예제 #2
0
        public async Task <OutMachineDTO> UpdateMachineAsync(int id, InMachineDTO machineDto)
        {
            var machine = await _machineRepository.GetById(id);

            if (machine != null)
            {
                Machine machineMapping = MachineMapping.InDtoToMachine(machineDto);
                machine.Description = machineMapping.Description;
                machine.MachineName = machineMapping.MachineName;
                var machineType = await _machineTypeRepository.GetById(machineDto.MachineType);

                machine.MachineType = machineType;
                machine.Active      = machineMapping.Active;
            }
            var createdMachine = await _machineRepository.Update(machine);

            var outMachineDto = MachineMapping.MachineToOutDto(createdMachine);

            return(outMachineDto);
        }