Example #1
0
        public async Task <IActionResult> GetList(string date)
        {
            SAPContext context = HttpContext.RequestServices.GetService(typeof(SAPContext)) as SAPContext;

            SAPbobsCOM.Documents items   = (SAPbobsCOM.Documents)context.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseDeliveryNotes);
            SAPbobsCOM.Recordset oRecSet = (SAPbobsCOM.Recordset)context.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
            List <Object>        list    = new List <Object>();

            oRecSet.DoQuery("Select * From OPDN Where \"DocDate\" = '" + date + "'");
            int rc = oRecSet.RecordCount;

            if (rc == 0)
            {
                return(NotFound());
            }
            items.Browser.Recordset = oRecSet;
            items.Browser.MoveFirst();

            while (items.Browser.EoF == false)
            {
                JToken temp = context.XMLTOJSON(items.GetAsXML());
                temp["OPDN"] = temp["OPDN"][0];
                temp["PDN4"]?.Parent.Remove();
                temp["PDN12"]?.Parent.Remove();
                temp["BTNT"]?.Parent.Remove();
                list.Add(temp);
                items.Browser.MoveNext();
            }

            return(Ok(list));
        }