Example #1
0
        public ActionResult <ResultResponse> createOPKL([FromBody] List <OpenSalesOrder> list)
        {
            // List<OpenSalesOrder> sortedList = list.OrderBy(si => si.DocNum).ToList();

            // var container = new List<OpenSalesOrder>();
            // for (int i = 0; i < sortedList.Count; i++)
            // {
            //         int comparisonIndex
            // }
            OPKLViewModel opklVM = new OPKLViewModel();
            List <OPKLContentViewModel> opklContentList = new List <OPKLContentViewModel>();

            foreach (var obj in list)
            {
                opklContentList.Add(new OPKLContentViewModel()
                {
                    OrderEntry     = obj.DocEntry,
                    OrderLine      = obj.LineNum,
                    BaseObjectType = obj.ObjType,
                    RelQtty        = obj.QtyToPost
                });
            }
            opklVM.opklContent = opklContentList;
            var result = postPickList(opklVM);

            return(result);
        }
Example #2
0
        private ResultResponse postPickList(OPKLViewModel model)
        {
            SAPbobsCOM.PickLists oOpkl = (SAPbobsCOM.PickLists)DIApi._oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPickLists);

            // header
            // oOpkl.PickDate = model.PickDate;
            // oOpkl.Remarks = model.Remarks;

            // rows
            foreach (var opklc in model.opklContent)
            {
                oOpkl.Lines.OrderEntry       = opklc.OrderEntry;
                oOpkl.Lines.OrderRowID       = opklc.OrderLine;
                oOpkl.Lines.BaseObjectType   = opklc.BaseObjectType;
                oOpkl.Lines.ReleasedQuantity = Convert.ToDouble(opklc.RelQtty);
                oOpkl.Lines.Add();
            }

            int lRetCode = oOpkl.Add();

            if (lRetCode == 0)
            {
                return(new ResultResponse
                {
                    Result = "Success",
                    Message = "Transaction successfuly posted",
                    ResultData = ""
                });
            }
            else
            {
                return(new ResultResponse
                {
                    Result = "Failed",
                    Message = DIApi._oCompany.GetLastErrorDescription(),
                    ResultData = ""
                });
            }
        }