Пример #1
0
        public async Task <OutOperationDTO> CreateOperationAsync(InOperationDTO inOperationDto)
        {
            var oOperation = OperationMapping.InDTOToOperation(inOperationDto);

            oOperation.Tool = await _toolRepository.GetByName(inOperationDto.Tool);

            var operation = await _operationRepository.Create(oOperation);

            var outOperationDto = OperationMapping.OperationToOutDTO(operation);

            return(outOperationDto);
        }
Пример #2
0
        public async Task <OutOperationDTO> UpdateOperationAsync(int operationId, InOperationDTO inOperationDto)
        {
            var operation = await _operationRepository.GetById(operationId);

            if (operation != null)
            {
                Operation operationMapping = OperationMapping.InDTOToOperation(inOperationDto);
                operation.Description   = operationMapping.Description;
                operation.OperationName = operationMapping.OperationName;
                operation.TimeTakes     = operationMapping.TimeTakes;
                operation.StartupTime   = operationMapping.StartupTime;
                var tool = await _toolRepository.GetByName(inOperationDto.Tool);

                operation.Tool = tool;
            }
            var updatedOperation = await _operationRepository.Update(operation);

            var outOperationDto = OperationMapping.OperationToOutDTO(updatedOperation);

            return(outOperationDto);
        }