// GET: api/OnlineContracts/5
        public HttpResponseMessage Get(string id)
        {
            Online_log.Info($"Get Opportunity {id.ToString()}");

            HttpResponseMessage response;

            Opp c = new Opp();

            String ln = "";
            BusinessEntityCollection fcontact = c.searchOpportunity(id);

            foreach (DynamicEntity cont1 in fcontact.BusinessEntities)
            {
                ln = cont1["name"].ToString();
            }

            if ((ln != ""))
            {
                response = Request.CreateResponse(HttpStatusCode.OK, ln);
            }
            else
            {
                response = Request.CreateResponse(HttpStatusCode.NoContent, ln);
            }

            return(response);
        }
        public HttpResponseMessage Get(string id)
        {
            string XML = "";

            Integration1C_log.Info($"Integration1C. Get id='{id}'");
            //595CC35C-30D2-E911-80CC-005056BAC107
            BusinessEntityCollection opportunity;
            Opp        o                     = new Opp();
            string     nameopp               = "";               //номер договора
            Lookup     new_contact2id        = new Lookup();     //Законный представитель ФЛ/ Подписант ЮЛ
            CrmBoolean new_pay_installments  = new CrmBoolean(); //рассрочка в банке
            CrmFloat   new_discountpercent   = new CrmFloat();   //% комиссии банка
            CrmMoney   new_commission_amount = new CrmMoney();   //Сумма комиссии банка
            CrmMoney   new_totalsumcost      = new CrmMoney();   //Общая стоимость обучения с учетом пособий

            try
            {
                opportunity = o.searchOpportunity(id);
                foreach (DynamicEntity opp in opportunity.BusinessEntities)
                {
                    nameopp = opp["name"].ToString();

                    if (opp.Properties.Contains("new_contact2id"))
                    {
                        new_contact2id = (Lookup)opp["new_contact2id"];
                    }

                    if (opp.Properties.Contains("new_pay_installments"))
                    {
                        new_pay_installments = (CrmBoolean)opp["new_pay_installments"];
                    }

                    if (opp.Properties.Contains("new_discountpercent"))
                    {
                        new_discountpercent = (CrmFloat)opp["new_discountpercent"];
                    }

                    if (opp.Properties.Contains("new_commission_amount"))
                    {
                        new_commission_amount = (CrmMoney)opp["new_commission_amount"];
                    }

                    if (opp.Properties.Contains("new_totalsumcost"))
                    {
                        new_totalsumcost = (CrmMoney)opp["new_totalsumcost"];
                    }
                }


                XML = String.Format("<report><opportunityid>{0}</opportunityid><name>{1}</name><new_contact2id>{2}</new_contact2id><new_pay_installments>{3}</new_pay_installments><new_discountpercent>{4}</new_discountpercent><new_commission_amount>{5}</new_commission_amount><new_totalsumcost>{6}</new_totalsumcost></report>", id, nameopp, new_contact2id.Value.ToString(), new_pay_installments.Value, new_discountpercent.Value, new_commission_amount.Value, new_totalsumcost.Value);
                Integration1C_log.Info($"Integration1C. Response xml='{XML}'");
                return(new HttpResponseMessage()
                {
                    Content = new StringContent(XML, Encoding.UTF8, "application/xml")
                });
            }
            catch (Exception ex)
            {
                XML = String.Format("<report><error>{0}</error></report>", ex.ToString());

                return(new HttpResponseMessage()
                {
                    Content = new StringContent(XML, Encoding.UTF8, "application/xml")
                });
            }
        }