Example #1
0
        static async Task <InboundICPFinal> PostInboundICPFinal(string path, InboundICPFinal inboundICPFinal)
        {
            HttpResponseMessage response = await client.PostAsJsonAsync(path, inboundICPFinal);

            if (response.IsSuccessStatusCode)
            {
                // Deserialize the updated InboundICPFinal from the response body.
                inboundICPFinal = await response.Content.ReadAsAsync <InboundICPFinal>();

                return(inboundICPFinal);
            }
            else
            {
                HandleErrors((int)response.StatusCode, response.ReasonPhrase, "PostInboundICPFinal", "", "APICall");
                return(null);
            }
        }
Example #2
0
        private static async Task RunWebAPITestsAsync(bool testAuth)
        {
            try
            {
                Console.WriteLine("Run WebAPI Tests Async started");
                Console.WriteLine("Run Test Auth: {0}", testAuth);
                InitializeHTTPClient(testAuth);

                if (testAuth)
                {
                    //************************************************************** Check if BarCodeExists (GetICPBarCodeExists) ******************************************************
                    string barcode = "RW11-12531";
                    var    urlParametersICPBarCode = new Dictionary <string, string>();
                    urlParametersICPBarCode.Add("Bcode", barcode);
                    String parametersICPBarCode     = BuildURLParametersString(urlParametersICPBarCode);
                    string path_GetICPBarCodeExists = "InboundICPFinals/GetICPBarCodeExists" + parametersICPBarCode;

                    bool iCPBarCodeExists = await CheckExists(path_GetICPBarCodeExists, "GetICPBarCodeExists");

                    Console.WriteLine($"iCPBarCodeExists {iCPBarCodeExists}");
                }
                else
                {
                    //************************************************************** Check if BarCodeExists (GetICPBarCodeExists) ******************************************************
                    string barcode = "RW11-12531";
                    var    urlParametersICPBarCode = new Dictionary <string, string>();
                    urlParametersICPBarCode.Add("Bcode", barcode);
                    String parametersICPBarCode     = BuildURLParametersString(urlParametersICPBarCode);
                    string path_GetICPBarCodeExists = "InboundICPFinals/GetICPBarCodeExists" + parametersICPBarCode;

                    bool iCPBarCodeExists = await CheckExists(path_GetICPBarCodeExists, "GetICPBarCodeExists");

                    Console.WriteLine($"iCPBarCodeExists {iCPBarCodeExists}");

                    //**************************************************************Create InboundICPFinal (PostInboundICPFinal) ********************************************************
                    if (!iCPBarCodeExists)
                    {
                        string          type                     = "10";
                        int             tableSampleID            = 126;
                        string          path_PostInboundICPFinal = "InboundICPFinals/PostInboundICPFinal/";
                        MakeICPInbound  MI = new MakeICPInbound();
                        InboundICPFinal inboundICPFinal = MI.makeICP(barcode, type, tableSampleID);

                        var updatedInboundICPFinal = await PostInboundICPFinal(path_PostInboundICPFinal, inboundICPFinal);

                        Console.WriteLine($"UpdatedInboundICPFinal ID: {updatedInboundICPFinal.ID.ToString()}");
                    }

                    //************************************************************** Check if Bar Code exists in New Exp table (GetNewExpBarCodeExists) **********************************
                    var urlParametersNewExpBarCode = new Dictionary <string, string>();
                    urlParametersNewExpBarCode.Add("Bcode", barcode);
                    String parametersNewExpBarCode     = BuildURLParametersString(urlParametersNewExpBarCode);
                    string path_GetNewExpBarCodeExists = "InboundICPFinals/GetNewExpBarCodeExists" + parametersNewExpBarCode;

                    bool newExpBarCodeExists = await CheckExists(path_GetNewExpBarCodeExists, "GetNewExpBarCodeExists");

                    Console.WriteLine($"newExpBarCodeExists {newExpBarCodeExists}");

                    //************************************************************** Check if Sample exists in Samples table (GetSampleExists) **********************************
                    var urlParametersSampleNumber = new Dictionary <string, string>();
                    urlParametersSampleNumber.Add("samplenumber", "9876201604041035");
                    String parametersSampleNumber = BuildURLParametersString(urlParametersSampleNumber);
                    string path_GetSampleExists   = "InboundICPFinals/GetSampleExists" + parametersSampleNumber;

                    bool sampleExists = await CheckExists(path_GetSampleExists, "GetSampleExists");

                    Console.WriteLine($"sampleExists {sampleExists}");
                }
            }
            catch (Exception ex)
            {
                HandleErrors(0, "", "RunWebAPITestsAsync", ex.StackTrace, "Main");
            }
        }