Пример #1
0
        public async Task <OutOperationDTO> GetOperationByNameAsync(string name)
        {
            Expression <Func <Operation, bool> > withName = m => m.OperationName.Equals(name);
            var operation = await _operationRepository.FirstOrDefault(withName);

            return(OperationMapping.OperationToOutDTO(operation));
        }
Пример #2
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);
        }
Пример #3
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);
        }
Пример #4
0
        public async Task <OutOperationDTO> GetOperationByIdAsync(int id)
        {
            var operation = await _operationRepository.GetById(id);

            return(OperationMapping.OperationToOutDTO(operation));
        }
Пример #5
0
        public async Task <IEnumerable <OutOperationDTO> > GetOperationsAsync(int from, int take)
        {
            var operations = await _operationRepository.GetAll(from, take);

            return(OperationMapping.OperationToOutDTO(operations));
        }