A doubt. Before the service returned values in the following signature: Predicted / Made , this made it much easier. Now the subscription has changed to this:
{
"CorIndicador":"VERMELHO",
"DadosIndicador":"{\"Previsto\":25784.686452608872,\"Realizado\":95258.9557949728}",
"TipoIndicador":1
}
with the previous signature of the IndicatorItem class that was like this:
public string Nome { get; set; }
public decimal Valor { get; set; }
Now with the new signature, you have entered two new CorIndicator and TypeIndicator fields. How would I make the class popular?
public class IndicadorData : List<IndicadorItem>
{}
So I deserealize
var resp = JsonConvert.DeserializeObject<KpiResponse>(response.Content);
This is the Kpi class
[DataContract]
public class KpiResponse
{
[DataMember]
public TipoIndicador TipoIndicador { get; set; }
[DataMember]
public string CorIndicador { get; set; }
[DataMember]
public string DadosIndicador { get; set; }
}
After deserializing in the kpi class, I do so to get the DataId
var fat = JsonConvert.DeserializeObject<FaturamentoResponse>(resp.DadosIndicador);
This is the class BillingResponse
public class FaturamentoResponse
{
public double Previsto { get; set; }
public double Realizado { get; set; }
}
That's exactly what I have. What should I do in this case to populate this class (IndicatorItem)? Just the way it is. What is the best way to do this?
EDIT1
I changed the IndicatorData class by adding the CorIndicator field and at the time of consuming the Service, in switch..case
I do this:
var fat = JsonConvert.DeserializeObject<FaturamentoResponse>(resp.DadosIndicador);
res.CorIndicador = resp.CorIndicador;
res.Add(new IndicadorItem { Nome = "Realizado", Valor = Convert.ToDecimal(fat.Realizado) });
res.Add(new IndicadorItem { Nome = "Previsto", Valor = Convert.ToDecimal(fat.Previsto) });