Esempio n. 1
0
        public static InOperationDTO OperationToInDTO(Operation operation)
        {
            var inOperationDto = new InOperationDTO()
            {
                Name        = operation.OperationName,
                Description = operation.Description,
                TimeTakes   = operation.TimeTakes,
                StartupTime = operation.StartupTime
            };

            return(inOperationDto);
        }
Esempio n. 2
0
        public static Operation InDTOToOperation(InOperationDTO inOperationDto)
        {
            var operation = new Operation
            {
                OperationName = (inOperationDto.Name),
                Description   = (inOperationDto.Description),
                TimeTakes     = (inOperationDto.TimeTakes),
                StartupTime   = inOperationDto.StartupTime
            };

            return(operation);
        }
Esempio n. 3
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);
        }
Esempio n. 4
0
        public async Task <IActionResult> Put(int id, [FromBody] InOperationDTO inOperationDto)
        {
            try
            {
                await _operationService.UpdateOperationAsync(id, inOperationDto);

                return(NoContent());
            }
            catch (Exception e)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }
Esempio n. 5
0
        public async Task <IActionResult> Post([FromBody] InOperationDTO operationDto)
        {
            try
            {
                var operation = await _operationService.CreateOperationAsync(operationDto);

                return(Created(nameof(Post), operation));
            }
            catch (Exception e)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }
Esempio n. 6
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);
        }
Esempio n. 7
0
        /// <summary>
        ///
        /// </summary>
        /// <exception cref="factory.api.client.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="id"></param>
        /// <param name="inOperationDTO"></param>
        /// <returns>ApiResponse of Object(void)</returns>
        public factory.api.client.Client.ApiResponse <Object> OperationsPutWithHttpInfo(int id, InOperationDTO inOperationDTO)
        {
            // verify the required parameter 'id' is set
            if (id == null)
            {
                throw new factory.api.client.Client.ApiException(400, "Missing required parameter 'id' when calling OperationsApi->OperationsPut");
            }

            // verify the required parameter 'inOperationDTO' is set
            if (inOperationDTO == null)
            {
                throw new factory.api.client.Client.ApiException(400, "Missing required parameter 'inOperationDTO' when calling OperationsApi->OperationsPut");
            }

            factory.api.client.Client.RequestOptions requestOptions = new factory.api.client.Client.RequestOptions();

            String[] @contentTypes = new String[] {
                "application/json"
            };

            // to determine the Accept header
            String[] @accepts = new String[] {
                "application/json"
            };

            var localVarContentType = factory.api.client.Client.ClientUtils.SelectHeaderContentType(@contentTypes);

            if (localVarContentType != null)
            {
                requestOptions.HeaderParameters.Add("Content-Type", localVarContentType);
            }

            var localVarAccept = factory.api.client.Client.ClientUtils.SelectHeaderAccept(@accepts);

            if (localVarAccept != null)
            {
                requestOptions.HeaderParameters.Add("Accept", localVarAccept);
            }

            if (id != null)
            {
                requestOptions.PathParameters.Add("id", factory.api.client.Client.ClientUtils.ParameterToString(id)); // path parameter
            }
            requestOptions.Data = inOperationDTO;


            // make the HTTP request

            var response = this.Client.Put <Object>("/api/v1/operations/{id}", requestOptions, this.Configuration);

            if (this.ExceptionFactory != null)
            {
                Exception exception = this.ExceptionFactory("OperationsPut", response);
                if (exception != null)
                {
                    throw exception;
                }
            }

            return(response);
        }
Esempio n. 8
0
 /// <summary>
 ///
 /// </summary>
 /// <exception cref="factory.api.client.Client.ApiException">Thrown when fails to make API call</exception>
 /// <param name="id"></param>
 /// <param name="inOperationDTO"></param>
 /// <returns></returns>
 public void OperationsPut(int id, InOperationDTO inOperationDTO)
 {
     OperationsPutWithHttpInfo(id, inOperationDTO);
 }
Esempio n. 9
0
        /// <summary>
        ///
        /// </summary>
        /// <exception cref="factory.api.client.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="inOperationDTO"></param>
        /// <returns>Task of ApiResponse</returns>
        public async System.Threading.Tasks.Task <factory.api.client.Client.ApiResponse <Object> > OperationsPostAsyncWithHttpInfo(InOperationDTO inOperationDTO)
        {
            // verify the required parameter 'inOperationDTO' is set
            if (inOperationDTO == null)
            {
                throw new factory.api.client.Client.ApiException(400, "Missing required parameter 'inOperationDTO' when calling OperationsApi->OperationsPost");
            }


            factory.api.client.Client.RequestOptions requestOptions = new factory.api.client.Client.RequestOptions();

            String[] @contentTypes = new String[] {
                "application/json"
            };

            // to determine the Accept header
            String[] @accepts = new String[] {
                "application/json"
            };

            foreach (var contentType in @contentTypes)
            {
                requestOptions.HeaderParameters.Add("Content-Type", contentType);
            }

            foreach (var accept in @accepts)
            {
                requestOptions.HeaderParameters.Add("Accept", accept);
            }

            requestOptions.Data = inOperationDTO;


            // make the HTTP request

            var response = await this.AsynchronousClient.PostAsync <Object>("/api/v1/operations", requestOptions, this.Configuration);

            if (this.ExceptionFactory != null)
            {
                Exception exception = this.ExceptionFactory("OperationsPost", response);
                if (exception != null)
                {
                    throw exception;
                }
            }

            return(response);
        }
Esempio n. 10
0
 /// <summary>
 ///
 /// </summary>
 /// <exception cref="factory.api.client.Client.ApiException">Thrown when fails to make API call</exception>
 /// <param name="inOperationDTO"></param>
 /// <returns>Task of void</returns>
 public async System.Threading.Tasks.Task OperationsPostAsync(InOperationDTO inOperationDTO)
 {
     await OperationsPostAsyncWithHttpInfo(inOperationDTO);
 }
Esempio n. 11
0
 /// <summary>
 ///
 /// </summary>
 /// <exception cref="factory.api.client.Client.ApiException">Thrown when fails to make API call</exception>
 /// <param name="inOperationDTO"></param>
 /// <returns></returns>
 public void OperationsPost(InOperationDTO inOperationDTO)
 {
     OperationsPostWithHttpInfo(inOperationDTO);
 }