public void Atualizar(UsuarioTO to) { _Contexto = ControladorAcesso.ObterContexto(); if (to.Identificador == 0 || to == null) { to.Valido = false; to.Mensagem = Mensagem.Atualizacao("Usuario", false); return; } Usuario entidade = _Contexto.Usuario.FirstOrDefault(x => x.Identificador == to.Identificador); if (entidade == null) { to.Valido = false; to.Mensagem = Mensagem.Obter("Usuario", false); return; } to.PreencherEntidade(entidade); _Contexto.SaveChanges(); to.PreencherTO(entidade); to.Valido = true; to.Mensagem = Mensagem.Atualizacao("Usuario", true); return; }
public void Cadastrar(UsuarioTO to) { _Contexto = ControladorAcesso.ObterContexto(); Usuario entidade = new Usuario(); to.PreencherEntidade(entidade); _Contexto.Usuario.Add(entidade); _Contexto.SaveChanges(); to.PreencherTO(entidade); to.Valido = true; to.Mensagem = Mensagem.Cadastro("Usuario"); return; }