コード例 #1
0
 public static ProductionLine InDTOToProductionLine(InProductionLineDTO productionLineDTO)
 {
     return(new ProductionLine
     {
         ProductionName = (productionLineDTO.Name),
         Description = (productionLineDTO.Description),
     });
 }
コード例 #2
0
        public async Task <ActionResult> Post([FromBody] InProductionLineDTO inProductionLineDto)
        {
            try
            {
                var productionLine = await _productionLineService.CreateProductionLineAsync(inProductionLineDto);

                return(Created(nameof(Post), productionLine));
            }
            catch (Exception e)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
            }
        }
コード例 #3
0
        public async Task <IActionResult> Put(int id, [FromBody] InProductionLineDTO inProductionLineDto)
        {
            try
            {
                await _productionLineService.UpdateProductionLineAsync(id, inProductionLineDto);

                return(NoContent());
            }
            catch (Exception e)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
            }
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        /// <summary>
        ///
        /// </summary>
        /// <exception cref="factory.api.client.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="id"></param>
        /// <param name="inProductionLineDTO"></param>
        /// <returns>ApiResponse of Object(void)</returns>
        public factory.api.client.Client.ApiResponse <Object> ProductionLinesPutWithHttpInfo(int id, InProductionLineDTO inProductionLineDTO)
        {
            // verify the required parameter 'id' is set
            if (id == null)
            {
                throw new factory.api.client.Client.ApiException(400, "Missing required parameter 'id' when calling ProductionLinesApi->ProductionLinesPut");
            }

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

            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 = inProductionLineDTO;


            // make the HTTP request

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

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

            return(response);
        }
コード例 #6
0
 /// <summary>
 ///
 /// </summary>
 /// <exception cref="factory.api.client.Client.ApiException">Thrown when fails to make API call</exception>
 /// <param name="id"></param>
 /// <param name="inProductionLineDTO"></param>
 /// <returns></returns>
 public void ProductionLinesPut(int id, InProductionLineDTO inProductionLineDTO)
 {
     ProductionLinesPutWithHttpInfo(id, inProductionLineDTO);
 }
コード例 #7
0
        /// <summary>
        ///
        /// </summary>
        /// <exception cref="factory.api.client.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="inProductionLineDTO"></param>
        /// <returns>Task of ApiResponse</returns>
        public async System.Threading.Tasks.Task <factory.api.client.Client.ApiResponse <Object> > ProductionLinesPostAsyncWithHttpInfo(InProductionLineDTO inProductionLineDTO)
        {
            // verify the required parameter 'inProductionLineDTO' is set
            if (inProductionLineDTO == null)
            {
                throw new factory.api.client.Client.ApiException(400, "Missing required parameter 'inProductionLineDTO' when calling ProductionLinesApi->ProductionLinesPost");
            }


            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 = inProductionLineDTO;


            // make the HTTP request

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

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

            return(response);
        }
コード例 #8
0
 /// <summary>
 ///
 /// </summary>
 /// <exception cref="factory.api.client.Client.ApiException">Thrown when fails to make API call</exception>
 /// <param name="inProductionLineDTO"></param>
 /// <returns>Task of void</returns>
 public async System.Threading.Tasks.Task ProductionLinesPostAsync(InProductionLineDTO inProductionLineDTO)
 {
     await ProductionLinesPostAsyncWithHttpInfo(inProductionLineDTO);
 }
コード例 #9
0
 /// <summary>
 ///
 /// </summary>
 /// <exception cref="factory.api.client.Client.ApiException">Thrown when fails to make API call</exception>
 /// <param name="inProductionLineDTO"></param>
 /// <returns></returns>
 public void ProductionLinesPost(InProductionLineDTO inProductionLineDTO)
 {
     ProductionLinesPostWithHttpInfo(inProductionLineDTO);
 }
コード例 #10
0
        public async Task <OutProductionLineDTO> UpdateProductionLineAsync(int productionLineId, InProductionLineDTO inProductionLineDto)
        {
            var productionLine = await _productionLineRepository.GetById(productionLineId);

            productionLine.Machines.Clear();
            productionLine.Description    = inProductionLineDto.Description;
            productionLine.ProductionName = inProductionLineDto.Name;
            foreach (var mId in inProductionLineDto.Machines)
            {
                var machine = await _machineRepository.GetById(mId);

                productionLine.Machines.Add(machine);
            }
            var updatedProductionLine = await _productionLineRepository.Update(productionLine);

            var outProductionLine = ProductionLineMapping.ProductionLineToOutDTO(updatedProductionLine);

            return(outProductionLine);
        }