private void PurchaseOrderUpdateMethod(new_aprove_price _proxyentity, List <new_port> _portList, OrganizationServiceContext orgContext, IOrganizationService service) { List <new_purchase_order> _orderListForUpdate = (from i in orgContext.CreateQuery <new_purchase_order>() where i.new_cropid.Id == _proxyentity.new_cropid.Id && (i.new_status == new OptionSetValue(100000000) || i.new_status == new OptionSetValue(100000001)) select i).ToList(); if (_orderListForUpdate != null) { foreach (var item in _orderListForUpdate) { new_purchase_order_change _newChangeOrder = new new_purchase_order_change(); _newChangeOrder.new_cropid = item.new_cropid; _newChangeOrder.new_purchase_price = item.new_purchase_price; _newChangeOrder.new_purchase_order = new EntityReference() { Id = item.Id, LogicalName = item.LogicalName }; service.Create(_newChangeOrder); new_purchase_order _updateOrder = new new_purchase_order(); _updateOrder.Id = item.Id; if (item.new_portid == null) { continue; } if (_portList.Where(x => x.Id == item.new_portid.Id).FirstOrDefault().new_name == "Одеса") { _updateOrder.new_purchase_price = _proxyentity.new_recom_purchase_price_odessa; } else if (_portList.Where(x => x.Id == item.new_portid.Id).FirstOrDefault().new_name == "Миколаїв") { _updateOrder.new_purchase_price = _proxyentity.new_recom_purchase_price_nikolaev; } service.Update(_updateOrder); } } }
private void PurchaseOrderUpdateMethod(new_aprove_price _proxyentity, List<new_port> _portList, OrganizationServiceContext orgContext, IOrganizationService service) { List<new_purchase_order> _orderListForUpdate = (from i in orgContext.CreateQuery<new_purchase_order>() where i.new_cropid.Id == _proxyentity.new_cropid.Id && (i.new_status == new OptionSetValue(100000000) || i.new_status == new OptionSetValue(100000001)) select i).ToList(); if ( _orderListForUpdate != null ) { foreach ( var item in _orderListForUpdate ) { new_purchase_order_change _newChangeOrder = new new_purchase_order_change(); _newChangeOrder.new_cropid = item.new_cropid; _newChangeOrder.new_purchase_price = item.new_purchase_price; _newChangeOrder.new_purchase_order = new EntityReference() { Id = item.Id, LogicalName = item.LogicalName }; service.Create(_newChangeOrder); new_purchase_order _updateOrder = new new_purchase_order(); _updateOrder.Id = item.Id; if ( item.new_portid == null ) continue; if ( _portList.Where(x => x.Id == item.new_portid.Id).FirstOrDefault().new_name == "Одеса" ) { _updateOrder.new_purchase_price = _proxyentity.new_recom_purchase_price_odessa; } else if ( _portList.Where(x => x.Id == item.new_portid.Id).FirstOrDefault().new_name == "Миколаїв" ) { _updateOrder.new_purchase_price = _proxyentity.new_recom_purchase_price_nikolaev; } service.Update(_updateOrder); } } }