I'm getting an error on some of my while loops when I try to replace some of my variables.
Below is the code for my main class:
int i = 0;
while (ships.Read())
{
product_id = ships.GetString(0);
unit_price = ships.GetDecimal(1);
currency = ships.GetString(2);
model.Events[i].Event_params.Product_id = product_id;
model.Events[i].Event_params.Unit_price = unit_price;
model.Events[i].Event_params.Currency = currency;
i++;
}
And below is my class structure to get and set the data.
public class InsiderCRMAPI
{
[JsonProperty("users")]
public Collection<UserModel> User = new Collection<UserModel>();
[JsonProperty("events")]
public Collection<EventModel> Events = new Collection<EventModel>();
}
public class EventModel
{
[JsonProperty("event_name")]
public string Event_name { get; set; }
[JsonProperty("timestamp")]
public string Timestamp { get; set; }
[JsonProperty("event_params")]
public ProductModel Event_params { get; set; } = new ProductModel();
[JsonProperty("taxonomy")]
public Collection<TaxModel> Taxonomy = new Collection<TaxModel>();
}
public class ProductModel
{
[JsonProperty("product_id")]
public string Product_id { get; set; }
[JsonProperty("unit_price")]
public decimal Unit_price { get; set; }
[JsonProperty("currency")]
public string Currency { get; set; }
[JsonProperty("custom")]
public CustomProdModel Custom { get; set; } = new CustomProdModel();
}
Any help with how to fix the issue or find what's causing the exception would be great!