Write a Json string in the database C #

0

I'm getting the data correctly, and getting them to separate correctly too, only problem is that I do not know how to use the values and be able to write to the database, could they help me?

The image below shows how I'm getting the data and treating it so far:

[HttpPost]publicasyncTask<IActionResult>SellAdd(stringproducts){varobjects=JsonConvert.DeserializeObject<List<object>>(products);string[]model=objects.Select(x=>x.ToString()).ToArray();foreach(varproductinmodel){//varprodutoCodigo=await_productManager.GetProductCodigoAsync();/*varvenda=newApplicationSell{Quantidade=product.quantidadeProduto,Total=product.valorTotalProduto,ProductId=produtoCodigo.Codigo};await_productManager.GravaVendaAsync(venda);*/}returnRedirectToAction("Index");
    }
    
asked by anonymous 21.11.2018 / 13:53

1 answer

0

Hello, in my humble opinion, you could use the entity framework to access the database.

Would create a class:

public class Products {
    int    codigoProduto {get;set;}
    int    quantidadeProduto {get;set;}
    double valorTotalProduto {get;set;}
}

Products  prod = JsonConvert.DeserializeObject<Products>(products);

Below you could access the properties prod.valorTotalProduto for example.

Next you would use the entity framework to write, update, or delete the database.

I hope I have helped something.

    
21.11.2018 / 14:09