Basit Nisar

Basit Nisar

  • 1.7k
  • 84
  • 11.1k

How to loop through key value pair receiving from Payload

Mar 28 2023 12:29 AM

The UI is sending the payload in the json format : [{"ContractInvoicePerDays":[{"33262":"2023-03-24T13:32:47.313"},{"33263":"2023-03-24T13:32:56.967"}]}]

it is comma seperated string 

my c# code is :

List<int> TimeCardIDs = cipdRejectedView.ContractInvoicePerDays.Split(',').Select(int.Parse).ToList();
if (TimeCardIDs.Count == 1)
{
    BaseStateProvinceID = cipdRejectedView.BaseStateProvinceID;
}
foreach (var item in TimeCardIDs)
{
    ContractInvoicePerDay contractInvoicePerDay = new ContractInvoicePerDay();
    int _ContractInvoicePerDayID = item;
    contractInvoicePerDay = db.ContractInvoicePerDays.Find(_ContractInvoicePerDayID);

 


Answers (2)