0
That way I add an item to session
var item = new FornecedorTipoFrete()
{
TipoFreteId = id,
TipoFrete = new TipoFrete() { Descricao = tipofrete },
FornecedorId = (fornecedorID)
};
HttpContext.Session.SetString("TipoFreteId", id.ToString());
However, this process can occur several times. The user can add multiple Types, so it could be one or several, as I can add all and then read this session with multiple items.
EDIT
I tried to do it this way:
I added this line to controller
IList<string> listaFrete = new List<string>();
and then to save in Session
did it this way:
listaFrete.Add(id.ToString());
HttpContext.Session.SetObject("Lista", listaFrete);
But he always picks up the last one, doesn’t save it in the list. There’s always only one item, always the last one.
cannot add an array or list of "Tipofreteid"?
– Ricardo Pontual
The form today accepts only one Typofreteid, the user will be able to include several, and will only save when Submit is performed, if no problems occur, can.
– Mariana
so I think you can fix it.. It will only take one more job to treat the list, and maybe remove/add items depending on if you have changes
– Ricardo Pontual
I need to add, add via Json, and to delete also delete via Json.
– Mariana
if you have a lot of maintenance maybe Session is not the best place, maybe a bank is better
– Ricardo Pontual
In this case, it is pq the user will include to save, he can include and decide not to terminate the registration. Would have some better way to do?
– Mariana
Session may lose if it closes the browser or it may expire.. a possibility would be to save to a "temporary" table or if you have a database in your environment for example. are options
– Ricardo Pontual
In case I think the session would be better.
– Mariana
Use cookies if this is the case. But still if you prefer to use Session I suggest saving an item list or array to Session
– Victor Laio
@Ricardopunctual I edited the question.
– Mariana