Click here to Skip to main content
15,790,807 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi I have one class and inside the class I have two lists and I want to send class object to post API

What I have tried:

public string AuthoryOfCertificate { get; set; }
public TimeSpan EstManHour { get; set; }
public string DefectDamage { get; set; }
public TimeSpan ActualManHour { get; set; }

public List<MaterialDetail> mmaterial { get; set; }

public List<ToolsDetailData> ttools { get; set; }

Here I am sending data to post API
public async void SaveNRC()
    CreateNRCMainClass obj = new CreateNRCMainClass();
    obj.CustomerName = AriregnCustomerName;
    obj.AircraftModel = AircraftModel;
    obj.AircraftRegn = aircraft;
    obj.AUTHNo = AUTHCERT;
    obj.Date = DateTime.Now;
    obj.FindingfromTask = FindingTaskData;
    obj.ATA = ATAData;
    obj.SUBATA = SubATA;
    obj.ZoneTrade = ZoneData;
    obj.TradeToAction = TradeToactionData;
    List<MaterialDetail> materialsobj =  DependencyService.Get<ISQLMaterialAndTools>().GetMyMaterials();
    List<ToolsDetailData> toolsDetailsobj = DependencyService.Get<ISQLMaterialAndTools>().GetTools();

    string objectdata = JsonConvert.SerializeObject(obj);
    WorkOrderApiHelper _workOrderApiHelper = new WorkOrderApiHelper();
    var data = await _workOrderApiHelper.SaveNRCToolAndMaterialData(obj);
Updated 11-May-23 1:48am

1 solution

At a guess, the problem is that you're storing the materials and tools lists in local variables, rather than in the properties on your obj instance:
obj.mmaterial =  DependencyService.Get<ISQLMaterialAndTools>().GetMyMaterials();
obj.ttools = DependencyService.Get<ISQLMaterialAndTools>().GetTools();

But that's just a guess, because you haven't actually explained what the problem is.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900