public void SalvarUsuario(string nome, string email, string senha, DateTime nascimnto) { try { var usuario = new CadastroDTO(); if (!string.IsNullOrEmpty(nome)) { usuario.Nome = nome; } if (!string.IsNullOrEmpty(email)) { usuario.Email = email; } if (!string.IsNullOrEmpty(senha)) { usuario.Senha = senha; } if (nascimnto.Date <= DateTime.Now.Date) { usuario.DataDeNascimento = nascimnto; } } catch (Exception) { throw; } }
public ActionResult Index(CadastroDTO dto) { dto.Cpf = StringHelper.FormatarCpf(dto.Cpf); var retorno = this.business.Login(dto.Senha, dto.Cpf); if (retorno != null) { LoginModels.SetLoginModel(new LoginModels { IdCadastro = retorno.IdCadastro, PrimeiroNome = retorno.PrimeiroNome, UltimoNome = retorno.UltimoNome, Cep = retorno.Cep, Complemento = retorno.Complemento, Cpf = retorno.Cpf, Email = retorno.Email, Endereco = retorno.Endereco, Numero = retorno.Numero, Rua = retorno.Rua, Senha = retorno.Senha, Sexo = retorno.Sexo, }); } if (LoginModels.IsLogado()) { return(RedirectToAction("index", "Cadastro")); } else { TempData["error"] = "Nenhum usuário encontrado."; return(View(dto)); } }
public ActionResult Create(Cadastro model) { if (this.business.Exists(model.Cpf)) { TempData["msgsucesso"] = "Cpf ja cadastrado"; return(View(model)); } if (custom.ValidationCPF.IsCpf(model.Cpf)) { try { var dto = new CadastroDTO { PrimeiroNome = model.PrimeiroNome, UltimoNome = model.UltimoNome, Cpf = model.Cpf, Sexo = model.Sexo, Senha = model.Senha, Endereco = model.Endereco, DataNascimento = model.DataNascimento, DataCadastro = DateTime.Now, Email = model.Email, Rua = model.Rua, Numero = model.Rua, Cep = model.Cep, Complemento = model.Complemento }; if (ModelState.IsValid) { this.business.Save(dto); TempData["msgsucesso"] = "Cadastro efetuado com sucesso"; } model.PrimeiroNome = string.Empty; model.UltimoNome = string.Empty; model.Cpf = string.Empty; model.Senha = string.Empty; model.Senha = string.Empty; model.Endereco = string.Empty; model.Email = string.Empty; model.Rua = string.Empty; model.Numero = string.Empty; model.Cep = string.Empty; model.Complemento = string.Empty; } catch (Exception exception) { TempData["msgerro"] = exception.Message.ToString(); return(View(model)); } } else { TempData["msgerro"] = "Cpf invalido"; } return(RedirectToAction("index", "cadastro")); }
public void SalvarUsuario(CadastroDTO cadastro) { try { string insert = @" insert into Usuarios (Nome,Email,Senha,DataDeNascimento) values()"; int v = DB.Execute(insert, new { cadastro.Nome, cadastro.Email, cadastro.Senha, cadastro.DataDeNascimento }); } catch (Exception ex) { log.ErrorFormat("Erro ao consultar banco de dados!!\n Error: {0}", ex); throw; } }
public ActionResult RecuperarSenha(CadastroDTO dto) { var retorno = this.business.ListarPorEmail(dto.Email); if (retorno != null) { var mensagem = string.Format( "<p>Prezado(a), {0},<br><br>Segue abaixo suas informações de acesso.<br><br>CPF: {1}<br>Senha: {2}</p>", retorno.PrimeiroNome, retorno.Cpf, retorno.Senha); TempData["sucesso"] = InfraStructre.Send.EnviarSenha(retorno.Email, mensagem, "Infromações de Acesso"); } else { TempData["error"] = "Nenhum usuário encontrado."; } return(View(dto)); }
public ActionResult Cadastro(CadastroDTO cadastroDTO) { if (!ModelState.IsValid) { return(BadRequest(cadastroDTO)); } var user = _mapper.Map <User>(cadastroDTO); user.PasswordHash = HasherExtension.HashPassword(user.PasswordHash); var verifyEmail = _userAppService.VerifyEmail(user.Email); if (verifyEmail) { return(BadRequest("E-mail já existente")); } _userAppService.Insert(user); _userAppService.Commit(); return(new ObjectResult(cadastroDTO)); }
public void Update(CadastroDTO dto) { this.data.Update(dto); }
public void Save(CadastroDTO dto) { this.data.Save(dto); }
public void Update(CadastroDTO dto) { this._context.Entry(dto).State = System.Data.Entity.EntityState.Modified; this._context.SaveChanges(); }
public void Save(CadastroDTO dto) { this._context.Cadastroes.Add(dto); this._context.SaveChanges(); }