Venalyn Sudaria

Venalyn Sudaria

  • NA
  • 98
  • 595

How to joint the data of 'MECH' to 'TECH' data?

Apr 25 2019 10:17 PM
I am trying to join the data of "MECHANICAL" to "TECHNICAL" but I don't know how to do it.
 
This is my current code that list all the Data under DecodedFactoryOptions: At first, I groupby every equipments by their Categories..
Here is my code:
  1. public static IEnumerable<VehicleFactoryOptionModel> GetFactoryOptions(IEnumerable<DecodedFactoryOption> options)  
  2. {  
  3. var optionEquipment = new List<VehicleFactoryOptionModel>();  
  4. if (options == nullreturn optionEquipment;  
  5. var optEquip = options.GroupBy(e => e.Category);  
  6. foreach (var equip in optEquip) {  
  7. var optionalEquipment = new VehicleFactoryOptionModel { Data = new List<VehicleCategoryOptionModel>()};  
  8. if (equip != null) { foreach (var eq in equip)  
  9. {  
  10. optionalEquipment.TypeId = eq.OptionHeaderId;  
  11. optionalEquipment.Description = eq.Description;  
  12. optionalEquipment.Data.Select(d => d.StyleIds == eq.AppliedStyleId);  
  13. optionalEquipment.chromeCode = eq.chromeCode;  
  14. optionalEquipment.oemCode = eq.oemCode;  
  15. optionalEquipment.optionKindId = eq.optionKindId;  
  16. if (eq.OptionCategoryId == nullcontinue;  
  17. FillOptionCategoryInfo(eq, optionalEquipment); } }  
  18. optionEquipment.Add(optionalEquipment); } return optionEquipment; }  
The result of the above code is this:
 
[
{
"TypeId": 1236,
"TypeName": "MECHANICAL",
"Data":
[ { "Description": "Engine: 5.7L V8 DOHC 32V FFV w/i-Force",
"Categories":
[ { "Id": 1052, "Name": "Engine-8 Cyl" } ],
"StyleIds": [ 362074, 362107 ] },
{ "Description": "Engine: 5.7L V8 DOHC 32V FFV w/i-Force",
"Categories": [ { "Id": 1213, "Name": "Fuel System-Flex Fuel" } ],
"StyleIds": [ 362074, 362107 ] } },
{ "TypeId": 1176,
"TypeName": "TECHNICAL",
"Data":
[ {
"Description": "Tires: P275/55R20 Bridgestone/Dunlop Performance",
"Categories":
[ { "Id": 1092, "Name": "Tire-Front-Performance" } ],
"StyleIds": [ 362074, 362107 ] },
{ "Description": "Tires: P275/55R20 Bridgestone/Dunlop Performance",
"Categories": [ { "Id": 1097, "Name": "Tire-Rear-Performance" } ],
"StyleIds": [ 362074, 362107 ] },
{
"TypeId": 10689,
"TypeName": "ENTERTAINMENT",
"Data":
[ {
"Description": "Radio: Entune Premium w/JBL Audio & Navigation -inc: AM/FM/HD radio, CD player MP3/WMA playback capability, high-resolution 7\" touch-screen display, auxiliary audio jack, USB 2.0 port, iPod connectivity and control, iTunes Tagging, traffic and weather, JBL speakers and amplifier, Bluetooth hands-free phone capability, phone book access, voice recognition and music streaming, Entune App Suite includes Bing, iHeartRadio, MovieTickets.com, OpenTable, Pandora, Yelp and Facebook Places; real-time info including traffic, weather, fuel prices, sports and stocks, SIRIUSXM Satellite Radio, 90-day free trial", "Categories": [ { "Id": 1014, "Name": "Audio-AM/FM Stereo" } ],
"StyleIds": [ 362074, 362107 ] },
{ "Description": "Radio: Entune Premium w/JBL Audio & Navigation -inc: AM/FM/HD radio, CD player MP3/WMA playback capability, high-resolution 7\" touch-screen display, auxiliary audio jack, USB 2.0 port, iPod connectivity and control, iTunes Tagging, traffic and weather, JBL speakers and amplifier, Bluetooth hands-free phone capability, phone book access, voice recognition and music streaming, Entune App Suite includes Bing, iHeartRadio, MovieTickets.com, OpenTable, Pandora, Yelp and Facebook Places; real-time info including traffic, weather, fuel prices, sports and stocks, SIRIUSXM Satellite Radio, 90-day free trial",
"Categories": [ { "Id": 1017, "Name": "Audio-CD Player" } ],
"StyleIds": [ 362074, 362107 ] },
 
I wanted the "MECHANICAL"'s data will be join into the "TECHNICAL" data. and the TypeName and TypeID of MECHANICAL will be removed but the DATA of it will be join/transfered to the TECHNICAL DATA

Answers (1)