1
Hello, I would like to make this comparison using a Guid
, public Guid ClienteID {get;set;}
. This code works using a int
, I make a if
, if my ClienteID == 0
I save, and if it doesn’t equal 0 I change.
I want a way to be able to do more than that to save and change.
public void Salvar(Cliente cliente)
{
if (cliente.ClienteID == 0)
{
cliente.DataCadastro = DateTime.Now;
_contexto.Clientes.Add(cliente);
}
else
{
Cliente cli = _contexto.Clientes.Find(cliente.ClienteID);
if (cli != null)
{
cli.Nome = cliente.Nome;
cli.Cpf = cliente.Cpf;
cli.Telefone = cliente.Telefone;
cli.Email = cliente.Email;
cli.Cep = cliente.Cep;
cli.Endereco = cliente.Endereco;
cli.Bairro = cliente.Bairro;
cli.Numero = cliente.Numero;
cli.Complemento = cliente.Complemento;
cli.DataCadastro = cli.DataCadastro;
}
}
_contexto.SaveChanges();
}
That one
Salvar
is called exactly where?– Leonel Sanches da Silva
All you had to do was put the
classe
Client, in your question, but, I made the two forms in the answer.– user46523