ASTE.Public.Rest.Controllers.PublicController.Process C# (CSharp) Метод

Process() приватный Метод

private Process ( Newtonsoft.Json.Linq.JObject json ) : Task
json Newtonsoft.Json.Linq.JObject
Результат Task
        public async Task<string> Process(JObject json)
        {
            //Serialize given json to model

            JsonPostModel model = json.ToObject<JsonPostModel>();
            //Get Api key from request headers
            var api_key = Request.Headers.Where(x => x.Key == "api_key").FirstOrDefault();

            if (api_key.Value != null)
            {
                string process = "";
                string method = "";
                string version = "";

                //Check mandatory values
                if (model.process == null)
                {
                    HttpResponseMessage response = this.Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Mandatory parameter missing: process");
                    throw new HttpResponseException(response);
                }
                else
                {
                    //Get process to be called from model
                    process = model.process;
                }
                if (model.method == null)
                {
                    HttpResponseMessage response = this.Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Mandatory parameter missing: method");
                    throw new HttpResponseException(response);
                }
                else
                {
                    //Get process method from model
                    method = model.method;
                }
                if (model.version == null)
                {
                    HttpResponseMessage response = this.Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Mandatory parameter missing: version");
                    throw new HttpResponseException(response);
                }
                else
                {
                    //Get Version
                    version = model.version;
                }



                //Create Resthelper
                RestHelper<object> rh = new RestHelper<object>();

                //Get Process info from API Discovery
                var data = await rh.GetConfig(process, method, api_key.Value.FirstOrDefault().ToString(), "1.0");

                if (data == null)
                {
                    //If process was not found, or process is not activated, return bad request
                    HttpResponseMessage response = this.Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Process not found.");
                    throw new HttpResponseException(response);
                }

                else
                {
                    //Get process url from API Data
                    var url = data.api_url;
                    //Call Process
                    var response = await rh.CallPostProcess(data.name, version, method, model.parameters, url, api_key.Value.FirstOrDefault().ToString());
                    //Return Data to APP
                    return response;
                }
            }
            else
            {
                //API Key missing, returning bad request
                HttpResponseMessage response = this.Request.CreateErrorResponse(HttpStatusCode.BadRequest, "API key missing.");
                throw new HttpResponseException(response);
            }

        }

Same methods

PublicController::Process ( string json ) : Task
PublicController