So far I have been trying to list items on ebay and allow Best Offers items.
I have tried this:
if (_eBayListingUtility.AllowBestOffer)
{
item.BestOfferEnabled = true;
item.BestOfferEnabledSpecified = true;
item.BestOfferDetails = new BestOfferDetailsType
{
BestOfferEnabled = true,
BestOfferEnabledSpecified = true,
};
item.ListingDetails = new ListingDetailsType
{
MinimumBestOfferMessage = _eBayListingUtility.MinimumBestOfferMessage,
MinimumBestOfferPrice = new AmountType
{
currencyID = CurrencyUtility.GetDefaultCurrencyCodeType(_context.Site),
Value = (double)_eBayListingUtility.MinimumBestOffer
},
BestOfferAutoAcceptPrice = new AmountType
{
currencyID = CurrencyUtility.GetDefaultCurrencyCodeType(_context.Site),
Value = (double)_eBayListingUtility.MinimumBestOffer
}
};
}
But that does not change anything. FYI, AllowBestOffer is a boolean for an item to be listed, and an item is an ItemType ebay class item.
I have tried this on an auction or fixed price item based on the AddItem api call, but all my items (ex: http://cgi.sandbox.ebay.com/110141411066?hash=item19a4dce3e0#ht_849wt_1397) does not show the "Best offer" button. So how can I achieve what I need to do?
Related
I am building a website that does has a chat component to it. The code below receives from a stored procedure a list of messages with a lots of different paramaters. 1 of those is if a message is in reply to another, and if that is the case, duplicate the message that is being replied to over the message answer. If the message that was being replied to was also an answer to a previous message do the same ect. Now my issue is that I have not been able to figure out how to automate this part of the code without nesting if into one another until a point where I hope users won't reply in the same chain anymore.
To rephrase it, I go in a list in inverse order and check if the ReplyingTo is not null.
I then copy the row that has the same ID and ReplyingTo 1 row higher than the current row.
I then confirm that this new row has a ReplyingTo
If it does I copy that object 2 row higher than the current one.
and I would continue this way until I reached a certain point that the users would not reach.
If anyone got an idea on how to proceed I would be highly gracious. I have put an example of the type of data that would be given to this function below.
for (int i = publicChatCountList.Count-1 ; i > -1; i--)
{
if (publicChatCountList[i].ReplyingTo.HasValue)
{
Chat_Dto chatItem = new Chat_Dto();
long? ReplyingToId = publicChatCountList[i].ReplyingTo;
chatItem = publicChatCountList.Find(x => x.Id == ReplyingToId);
publicChatCountList.Insert(i+1, new Chat_Dto() {Text = chatItem.Text, IsPublic = chatItem.IsPublic, IsApproved = chatItem.IsApproved, ReplyingTo = chatItem.ReplyingTo });
publicChatCountList[i+1].Duplicate = true;
if (chatItem.ReplyingTo.HasValue)
{
Chat_Dto chatItem2 = new Chat_Dto();
long? ReplyingToId2 = chatItem.ReplyingTo;
chatItem2 = publicChatCountList.Find(x => x.Id == ReplyingToId2);
publicChatCountList.Insert(i + 2, new Chat_Dto() { Text = chatItem2.Text, IsPublic = chatItem2.IsPublic, IsApproved = chatItem2.IsApproved, ReplyingTo = chatItem2.ReplyingTo });
publicChatCountList[i + 2].Duplicate = true;
}
}
}
If I understood you correctly maybe running something like this to recursively get all replies would work:
private void Replies(Chat_Dto_List publicChatCountList,int i)
{
if (publicChatCountList[i].ReplyingTo.HasValue)
{
Chat_Dto chatItem = new Chat_Dto();
long? ReplyingToId = publicChatCountList[i].ReplyingTo;
chatItem = publicChatCountList.Find(x => x.Id == ReplyingToId);
publicChatCountList.Insert(i + 1, new Chat_Dto() { Text = chatItem.Text, IsPublic = chatItem.IsPublic, IsApproved = chatItem.IsApproved, ReplyingTo = chatItem.ReplyingTo });
publicChatCountList[i + 1].Duplicate = true;
if (chatItem.ReplyingTo.HasValue)
{
Replies(publicChatCountList, publicChatCountList.FindIndex(x => x.Id == chatItem.ReplyingTo))
}
}
}
I'm trying to learn to use Entity Framework and am working through the Entity Framework Recipes 6 Book (not even going to try and hide that).
Working on 2-4:
3 tables:
Order: OrderID, OrderDate, (Nav Properties OrderItems)
OrderItem: OrderId, SKU, Count (Nav Properties, Item, Order)
Item: SKU, Description, Price (Nav Properties, OrderItems)
using (var context = new EFRecipesContext()) {
var order = new Order { OrderId = 1, OrderDate = new DateTime(2010, 1, 18) };
var item = new Item { SKU = 1729, Description = "Backpack", Price = 29.97M };
var oi = new OrderItem { Order = order, Item = item, Count = 1 };
item = new Item { SKU = 2929, Description = "Water Filter", Price = 13.97M };
oi = new OrderItem { Order = order, Item = item, Count = 3 };
item = new Item { SKU = 1847, Description = "Camp Stove", Price = 43.99M };
oi = new OrderItem { Order = order, Item = item, Count = 1 };
context.Orders.Add(order);
context.SaveChanges();
}
The only thing that gets added to the database is the order and nothing else, none of the items, etc... I had a problem with the previous example and had to add the "other" items individually but I thought that point was that you could just do the one "Add" and it would add all the objects to the Database?
Thanks in advance!
UPDATEOk I made the following changes based on the suggestions below and now it's working
using (var context = new EFRecipesContext()) {
var order = new Order { OrderId = 1, OrderDate = new DateTime(2010, 1, 18) };
var item = new Item { SKU = 1729, Description = "Backpack", Price = 29.97M };
var oi = new OrderItem { Order = order, Item = item, Count = 1 };
order.OrderItems.Add(oi); // suggestion from Stackoverflow.
item = new Item { SKU = 2929, Description = "Water Filter", Price = 13.97M };
oi = new OrderItem { Order = order, Item = item, Count = 3 };
order.OrderItems.Add(oi); // suggestion from Stackoverflow.
item = new Item { SKU = 1847, Description = "Camp Stove", Price = 43.99M };
oi = new OrderItem { Order = order, Item = item, Count = 1 };
order.OrderItems.Add(oi); // suggestion from Stackoverflow.
context.Orders.Add(order);
context.SaveChanges();
}
At least now I know what to change in their code going forward to get it working. Thanks!!
You never actually add the OrderItems to the DbContext collection.
There is also a problem with your code, which means you are overwriting your items and oi variable values multiple times.
The below code makes some assumptions, since you haven't supplied more of your code, but should be easy to adapt.
using (var context = new EFRecipesContext()) {
var order = new Order { OrderId = 1, OrderDate = new DateTime(2010, 1, 18) };
context.Orders.Add(order);
var item1 = new Item { SKU = 1729, Description = "Backpack", Price = 29.97M };
var oi1 = new OrderItem { Order = order, Item = item, Count = 1 };
context.OrderItems.Add(oi1);
var item2 = new Item { SKU = 2929, Description = "Water Filter", Price = 13.97M };
var oi2 = new OrderItem { Order = order, Item = item, Count = 3 };
context.OrderItems.Add(oi2);
var item3 = new Item { SKU = 1847, Description = "Camp Stove", Price = 43.99M };
var oi3 = new OrderItem { Order = order, Item = item, Count = 1 };
context.OrderItems.Add(oi3);
context.SaveChanges();
}
Unless you are using the variables again, you could do the definition of the objects inline like this aswell, which is slightly less repetitive:
context.OrderItems.Add(new OrderItem {
Order = order,
Item = new Item {
SKU = 1729,
Description = "Backpack",
Price = 29.97M
},
Count = 1
});
This is not really about many to many, but about the way how EF discovers related data.
You need to explicitely add the entry to the database, that is actually referencing the related data. In your case, this is oi, so if you add it
context.OrderItems.Add(oi);
context.SaveChanges();
the related io.Order and io.Item will be considered by EF. But EF has no way of knowing about this relation when you only provide order without providing navigation information from order to io.
Another way of solving the issue (instead of adding io explicitely) would be to update order.OrderItems before saving:
oi = new OrderItem { Order = order, Item = item, Count = 1 };
order.OrderItems.Add(oi);
context.Orders.Add(order);
context.SaveChanges();
You must add an entry to the database to be invoked on appropriate data. In this case, it's the OI.
In NetSuite SuiteTalk (Web Services), I am trying to create a search that will find all sales orders that have the status "Pending Approval". I think I have everything structured correctly and I think the problem is the status is not actually called "Pending Approval, but something else. I have tried other variants like "_pendingApproval", but my search never returns any results. If I comment out the status part, the search works correctly and returns every sales order for this particular customer.
Any thoughts on what the problem is?
C#
TransactionSearchBasic tsb = new TransactionSearchBasic() {
mainLine = new SearchBooleanField() {
searchValue = true,
searchValueSpecified = true,
},
type = new SearchEnumMultiSelectField() {
#operator = SearchEnumMultiSelectFieldOperator.anyOf,
operatorSpecified = true,
searchValue = new string[] { "_salesOrder" },
},
entity = new SearchMultiSelectField() {
#operator = SearchMultiSelectFieldOperator.anyOf,
operatorSpecified = true,
searchValue = new RecordRef[] {
new RecordRef() {
type = RecordType.customer,
internalId = "231"
}
}
},
status = new SearchEnumMultiSelectField() {
#operator = SearchEnumMultiSelectFieldOperator.anyOf,
operatorSpecified = true,
searchValue = new string[] {
"Pending Approval",
"_pendingApproval",
"pendingApproval",
"pendingapproval",
"pending approval",
"0"
}
}
};
SearchResult results = _nss.search(tsb);
It looks like the type of transaction needs to be prefixed to the status. For example:
status = new SearchEnumMultiSelectField() {
#operator = SearchEnumMultiSelectFieldOperator.anyOf,
operatorSpecified = true,
searchValue = new string[] {
"_salesOrderPendingApproval"
}
}
Try using :
"pendingApproval"
instead of
"_pendingApproval" & "Pending Approval"
I am using SuiteTalk web services (v. 2013_2) . I am trying to create an ItemFulfillment where the items in it were related to items that had a lot or serial number.
When I try to save this item fulfillment into NetSuite I get an error of :
Please commit inventorydetail on this line.
I was attempting to set the itemFulfillment.serialNumbers and itemFulfillment.binNumbers when I create the itemFulfillmentItem.
For example I set
nsIfItem.serialNumbers = "SNum(5)"
nsIfItem.binNumbers = "BNum(5)"
based on those properties being- A comma delimited list of serial or LOT numbers. If entering serial numbers there must be a number for each item.
Lot numbers must be entered in a format of LOT#(Quantity).
For example, to enter a quantity of 100 items as Lot number ABC1234, enter ABC1234(100).
Do I also need to set something else on the itemFulfillment or how do I get rid of that error.
I'm not sure if this question is still active, but I had the same issue and iI couldn't find much help on it. I solved this issue by creating the inventory assignment objects and adding to the transaction.
First, create the initialize ref for Item Fulfillment and assign the returned record to a variable:
InitializeRecord ir = new InitializeRecord();
ir.type = InitializeType.itemFulfillment;
InitializeRef iref = new InitializeRef();
iref.typeSpecified = true;
iref.type = InitializeRefType.salesOrder;
iref.internalId = 'Sales Order internalID';
ir.reference = iref;
ReadResponse getInitResp = _service.initialize(ir);
ItemFulfillment ifrec = (ItemFulfillment)getInitResp.record;
Get the list of items on the initialized transaction:
ItemFulfillmentItemList ifitemlist = ifrec.itemList;
Create a list to which to add each unique item being fulfilled:
List<ItemFulfillmentItem> ifitems = new List<ItemFulfillmentItem>();
Run the following code for each item in initialized transaction's item list:
If the current line item has already been added to the ifitems list, add the current Fulfillment line as an assignment to that item:
InventoryAssignment assignment = new InventoryAssignment
{
issueInventoryNumber = new RecordRef { internalId = 'internalID',
type = 'RecordType',
typeSpecified = true
}
};
List<InventoryAssignment> list = new List<InventoryAssignment>();
list.Add(assignment);
ifitemlist.item[b].inventoryDetail = new InventoryDetail
{
inventoryAssignmentList = new InventoryAssignmentList
{
inventoryAssignment = list.ToArray()
}
};
ifitemlist.item[b].quantity += 'quantity shipped';
If the line item has not yet been added, create new line item:
ItemFulfillmentItem ffItem = new ItemFulfillmentItem();
ffItem.item = ifitemlist.item[b].item;
ffItem.itemReceive = true;
ffItem.itemReceiveSpecified = true;
ffItem.itemIsFulfilled = true;
itemIsFulfilled = true;
ffItem.itemIsFulfilledSpecified = true;
ffItem.orderLineSpecified = true;
ffItem.orderLine = ifitemlist.item[b].orderLine;
//Check if serialized
if (Your fulfillment item contains serialized data)
{
ffItem.serialNumbers = 'Serial numbers';
InventoryAssignment assignment = new InventoryAssignment
{
issueInventoryNumber = new RecordRef {
internalId = 'Inventory internal ID',
type = RecordType,
typeSpecified = true
}
};
ffItem.inventoryDetail = new InventoryDetail
{
inventoryAssignmentList = new InventoryAssignmentList
{
inventoryAssignment = new InventoryAssignment[]
{
assignment
},
replaceAll = false
},
nullFieldList = new string[] { },
customForm = new RecordRef { }
};
}
ffItem.quantity = 'QUANTITY SHIPPED';
ffItem.quantitySpecified = true;
ifitems.Add(ffItem);
Finally, add your "ifitems" list to your Item Fulfillment and add this to NetSuite:
ItemFulfillmentItemList ifitemlistToFulfill = new ItemFulfillmentItemList();
ifitemlistToFulfill.replaceAll = false;
ifitemlistToFulfill.item = ifitems.ToArray();
ItemFulfillment newItemFulfill = new ItemFulfillment();
newItemFulfill.itemList = ifitemlistToFulfill;
_service.add(newItemFulfill);
I have an app that creates ContactList Objects and adds them to a Dictionary collection. My ContactList objects have a property called AggLabels which is a collection of AggregatedLabel objects containg Name and Count properties. What I am trying to do is change the "else" case of my code snippet so that before adding a new AggregatedLabel it will check whether the AggLabel.Name exists in the AggregatedLabel collection and if this is true it will not add the AggLabel.Name again. Instead it will add the value of AggLabel.Count (type int) to the existing AggregatedLabel object. So for an existing object, if the first Count value was 3 and the second value is 2 then the new Count value should be 5. In simple terms I want to have unique AggLabel Names and add together the Counts where the Names are the same. Hope that makes sense - would appreciate any help. Thanks!
Code snippet
Dictionary<int, ContactList> myContactDictionary = new Dictionary<int, ContactList>();
using (DB2DataReader dr = command.ExecuteReader())
{
while (dr.Read())
{
int id = Convert.ToInt32(dr["CONTACT_LIST_ID"]);
if (!myContactDictionary.ContainsKey(id))
{
ContactList contactList = new ContactList();
contactList.ContactListID = id;
contactList.ContactListName = dr["CONTACT_LIST_NAME"].ToString();
//contactList.AggLabels = new ObservableCollection<AggregatedLabel>() { new AggregatedLabel() { Name = dr["LABEL_NAME"].ToString(), Count = Convert.ToInt32(dr["LABEL_COUNT"])}};
contactList.AggLabels = new ObservableCollection<AggregatedLabel>()
{
new AggregatedLabel()
{
Name = dr["LABEL_NAME"].ToString(),
Count = Convert.ToInt32(dr["LABEL_COUNT"])
}
};
myContactDictionary.Add(id, contactList);
}
else
{
ContactList contactList = myContactDictionary[id];
contactList.AggLabels.Add(
new AggregatedLabel()
{
Name = dr["LABEL_NAME"].ToString(),
Count = Convert.ToInt32(dr["LABEL_COUNT"])
}
);
}
}
}
There are two possible solutions I can think of:
1) Use a dictionary instead of the collection of aggregated labels the same way you do it for the contact dictionary. When yout use the name as key and the count as value, you can use the ContainsKey-Method to check whether the label already exists.
contactList.AggLabels = new Dictionary<string, int>();
...
else
{
ContactList contactList = myContactDictionary[id];
if (contactList.AggLabels.ContainsKey(dr["LABEL_NAME"].ToString()))
{
contactList.AggLabels[dr["LABEL_NAME"].ToString()] += Convert.ToInt32(dr["LABEL_COUNT"]);
}
else
{
contactList.AggLabels.Add(dr["LABEL_NAME"].ToString(), Convert.ToInt32(dr["LABEL_COUNT"]));
}
}
2) I you need to use the AggreagteLabel object you can use a loop to search throug all labels.
else
{
bool flagAggLabelFound = false;
ContactList contactList = myContactDictionary[id];
foreach(AggregateLabel aggLabel in contactList.AggLabels)
{
if(aggLabel.Name == dr["LABEL_NAME"].ToString())
{
aggLabel.Count += Convert.ToInt32(dr["LABEL_COUNT"]);
flagAggLabelFound = true;
break;
}
}
if (!flagAggLabelFound)
{
contactList.AggLabels.Add(
new AggregatedLabel()
{
Name = dr["LABEL_NAME"].ToString(),
Count = Convert.ToInt32(dr["LABEL_COUNT"])
}
);
}
}
I hope this helps.
I would try this:
ContactList contactList = myContactDictionary[id];
AggregateLabel existing = contactList.AggLabels.FirstOrDefault(
l => l.Name == dr["LABEL_NAME"].ToString()
);
if (existing == null) { contactList.AggLabels.Add(
new AggregatedLabel() {
Name = dr["LABEL_NAME"].ToString(),
Count = Convert.ToInt32(dr["LABEL_COUNT"])
}
);
}
else { existing.Count += Convert.ToInt32(dr["LABEL_COUNT"]); }
#extract these Aggregated Labels and put them in a separate Observable collection:
1) If you a Dictionary for storing the labels in the contact list, this should work:
ObservableCollection<AggregateLabel> copyOfAggregateLabels = new ObservableCollection<AggregateLabel>();
foreach (KeyValuePair<string, int> aggLabel in aggregateLabels)
{
copyOfAggregateLabels.Add(
new AggregatedLabel() {
Name = aggLabel.Key,
Count = aggLabel.Value
}
);
}
2) If you use an ObservableCollection of AggregateLabels, you get an AggregateLable instead of a KeyValuePair in the loop. The rest works the same way.
First I thought of something like:
ObservableCollection<AggregateLabel> copyOfAggregateLabels = new ObservableCollection<AggregateLabel>(aggregateLables);
But this way you get a new ObservableCollection, but the labels stored in the new collection are still referring to the same objects as the ones in the collection you copy.