2
I’m passing an angular array through JSON this way:
$scope.gravaItem = function () {
$.ajax({
type: 'GET',
url: '/TaxaPreco/SalvarItens',
dataType: 'json',
contentType: "application/json; charset=utf-8",
data: { DeJson: JSON.stringify($scope.items) },
success: function (result) {
console.log('Data received: ');
console.log(result);
}
})
};
And in the controller
in this way:
public async Task<ActionResult> SalvarItens(string DeJson)
{
var arr = DeJson.Split(',');
var item = new TarifasPrecosItens()
{
De = arr[0],
Ate = "01:01",
Fracao = 0,
RepeteACada = 0,
TipoValor = 1,
Valor =5,
TararifaPrecosId = 25,
};
_context.TarifasPrecosItens.Add(item);
_context.SaveChanges();
return new JsonResult(DeJson);
}
in It receives the following value:
[{"of":"00:01"
How can I solve the value correctly? I need to get all the values, in this case I should just pick up:
00:01