I have SortedList collection. The key is a unique ProductID value whereas the value represents a Product item.
I am trying to find all product objects that have multiple Vendors (i.e with matching VendorID(UniqueIdentifier) properties). Then carry out some calculations on product properties e.g discount ShipingFee(decimal) property and the lowest obtained ItemPrice by 10% from each Vendors Product object.
With the exception of those with a ShippingFee equal to 0.0000 (database value).
The sortedlist should then be updated with the new ShippingFee and ItemPrice values in their original respective element
Example
vendor1 ,20.39
vendor2 ,10,30
vendor2 ,10,20
output
vendor2 11,22
Deepak RawatPosted Jun 26, 2023, 4:59 AM
To find the product objects with multiple vendors and perform calculations on their properties in the described manner, you can iterate over the
SortedListcollection and use a dictionary to keep track of products with multiple vendors. Here's an example implementation:GetSortedList()is a placeholder for the method that retrieves or initializes yourSortedListcollection. You would need to replace it with your actual implementation to obtain the sorted list of products.Please note that the above code assumes you have a
Productclass with properties likeProductID,VendorID,ShippingFee, andItemPrice. Adjust the code according to your actualProductclass structure.peterPosted Jun 26, 2023, 2:50 PM
Another issue that i did not include was the SortedList constructor. The key is a ProductID integer value whereaas in your example it is VendorID value. So i would not be able to update the list? and i need to keep this original sortedlist constructor with ProductID as key when insert display inside listview and database table.
ShoppingCart = CType(System.Web.HttpContext.Current.Session("Cart"), Collections.Generic.SortedList(Of Integer, Product))
peterPosted Jun 26, 2023, 2:22 PM
I got the output wrong as results should be
vendor2 ,11,30
vendor2 ,11,22
As i want to update all multiple vendor records with new shippingfee and itemprice ( only the lowest value)
Thanks