public LineItemDocument GetTransformedDocument(SalesOrderLinePayload payload, List <SyncFeedEntryLink> links) { LineItemDocument document = new LineItemDocument(); salesOrderLinetype salesOrder = payload.SalesOrderLinetype; #warning TODO: return(document); }
public SalesOrderLinePayload GetTransformedPayload(LineItemDocument document, out List <SyncFeedEntryLink> links) { SalesOrderLinePayload payload = new SalesOrderLinePayload(); salesOrderLinetype salesOrderLine = new salesOrderLinetype(); links = new List <SyncFeedEntryLink>(); #region initial values //Many more things should set to default values #endregion payload.SalesOrderLinetype = salesOrderLine; return(payload); }
public override SdataTransactionResult Update(PayloadBase payload, List <SyncFeedEntryLink> links) { SdataTransactionResult tmpTransactionResult; if (!(payload is SalesOrderLinePayload)) { tmpTransactionResult = new SdataTransactionResult(); tmpTransactionResult.HttpMethod = "PUT"; tmpTransactionResult.ResourceKind = _resourceKind; tmpTransactionResult.HttpStatus = System.Net.HttpStatusCode.BadRequest; tmpTransactionResult.HttpMessage = ("salesorder payload missing"); return(tmpTransactionResult); } salesOrderLinetype soLine = (payload as SalesOrderLinePayload).SalesOrderLinetype; DataSets.OrderTableAdapters.Order_DetailsTableAdapter detailsTableAdapter = new Order_DetailsTableAdapter(); DataSets.Order order = new DataSets.Order(); int productId; int orderId; if (GetLocalIds(payload.LocalID, out orderId, out productId)) { using (OleDbConnection connection = new OleDbConnection(_context.Config.ConnectionString)) { try { detailsTableAdapter.Connection = connection; int recordCount = detailsTableAdapter.FillBy(order.Order_Details, orderId); if (recordCount == 0) { tmpTransactionResult = new SdataTransactionResult(); tmpTransactionResult.LocalId = payload.LocalID; tmpTransactionResult.HttpMethod = "PUT"; tmpTransactionResult.ResourceKind = _resourceKind; tmpTransactionResult.HttpStatus = System.Net.HttpStatusCode.BadRequest; tmpTransactionResult.HttpMessage = ("salesorder not found"); return(tmpTransactionResult); } foreach (Sage.Integration.Northwind.Adapter.Data.SalesOrders.DataSets.Order.Order_DetailsRow detailsRow in order.Order_Details.Rows) { if (detailsRow.ProductID == productId) { detailsRow.ModifyUser = _context.Config.CrmUser; detailsRow.ModifyID = _context.Config.SequenceNumber; if (soLine.quantitySpecified) { detailsRow.Quantity = Convert.ToInt16(soLine.quantity); } else { detailsRow.Quantity = 0; } if (soLine.initialPriceSpecified) { detailsRow.UnitPrice = (Decimal)soLine.initialPrice; } else { detailsRow.UnitPrice = 0; } if ((!soLine.discountTotalSpecified) || (detailsRow.Quantity == 0) || (detailsRow.UnitPrice == 0)) { detailsRow.Discount = (float)0; } else { // discountPC = discountsum / qunatity * listprice //detailRow.Discount = Convert.ToSingle((decimal)lineItemDoc.discountsum.Value / ((decimal)detailRow.Quantity * detailRow.UnitPrice)); float discount = Convert.ToSingle((decimal)soLine.discountTotal / (detailsRow.UnitPrice)); if (discount > 1) { discount = 0; } detailsRow.Discount = discount; } break; } } detailsTableAdapter.Update(order.Order_Details); tmpTransactionResult = new SdataTransactionResult(); tmpTransactionResult.LocalId = payload.LocalID; tmpTransactionResult.HttpMethod = "PUT"; tmpTransactionResult.ResourceKind = _resourceKind; tmpTransactionResult.HttpStatus = System.Net.HttpStatusCode.OK; return(tmpTransactionResult); } catch (Exception e) { tmpTransactionResult = new SdataTransactionResult(); tmpTransactionResult.LocalId = payload.LocalID; tmpTransactionResult.HttpMethod = "PUT"; tmpTransactionResult.ResourceKind = _resourceKind; tmpTransactionResult.HttpStatus = System.Net.HttpStatusCode.BadRequest; tmpTransactionResult.HttpMessage = e.Message; return(tmpTransactionResult); } } } tmpTransactionResult = new SdataTransactionResult(); tmpTransactionResult.LocalId = payload.LocalID; tmpTransactionResult.HttpMethod = "PUT"; tmpTransactionResult.ResourceKind = _resourceKind; tmpTransactionResult.HttpStatus = System.Net.HttpStatusCode.BadRequest; tmpTransactionResult.HttpMessage = "Not found"; return(tmpTransactionResult); }