예제 #1
0
        public ActionResult <JobViewModel> Create([FromBody] JobDataContract jobParams)
        {
            Job job = _db.Jobs.Add(jobParams).Entity;

            _db.SaveChanges();
            _db.Entry(job).Reference(j => j.company).Load();

            return(Ok((JobViewModel)job));
        }
        public bool GetFPMAR(int jobNumber)
        {
            JobDataContract jsonResponse = new JobDataContract();

            //Set cookie
            string c_settings = "PHPSESSID=" + authorization.AuthToken;

            //Create request and send to ServiceTrade
            var client = new RestClient();

            client.EndPoint      = @uriStr + string.Format("job/{0}", jobNumber);
            client.Method        = HttpVerb.GET;
            client.ContentType   = "application/json";
            client.SessionCookie = c_settings;

            using (var response = client.MakeRequest())
            {
                if (response != null && response.StatusCode == HttpStatusCode.OK)
                {
                    try
                    {
                        DataContractJsonSerializer jsonSerializer = new DataContractJsonSerializer(typeof(JobDataContract));
                        object objResponse = jsonSerializer.ReadObject(response.GetResponseStream());
                        jsonResponse = objResponse as JobDataContract;
                    }
                    catch (Exception ex)
                    {
                        st.insertLog(ex.Message, "Exception Error", jobNumber.ToString(), HillerServiceDataMigrator.LogId);
                    }
                    finally
                    {
                        response.Close();
                    }
                }
            }

            if (jsonResponse.Job != null && jsonResponse.Job.ServiceRequests.Length > 0)
            {
                for (int i = 0; i < jsonResponse.Job.ServiceRequests.Length; i++)
                {
                    //check if Service line ID is not null
                    if (jsonResponse.Job.ServiceRequests[i].ServiceLineId != null)
                    {
                        if (CheckServiceLines(jsonResponse.Job.ServiceRequests[i].ServiceLineId))
                        {
                            return(true);
                        }
                    }
                }
            }

            //No FPMAR abbreviation were hit
            return(false);
        }