public async Task <ActionResult <Models.Response.AlterarUsuarioResponse> > AlterarUsuarioAsync(Models.Request.AlterarUsuarioRequest req) { try { esqueciSenhaBsn.ValidarSenhasIdenticas(req.Senha, req.ConfirmarSenha); Models.TbLogin tbLoginAtual = await usuarioBsn.ConsultarLoginPorEmailAsync(req.Email); Models.TbLogin tbLoginNovo = usuarioCnv.ToTbLogin(req); Models.TbUsuario tbUsuarioNovo = usuarioCnv.ToTbUsuario(req); Models.TbUsuario tbUsuarioAtual = await usuarioBsn.ConsultarUsuarioPorIdLoginAsync(tbLoginAtual.IdLogin); tbLoginAtual = await usuarioBsn.AlterarLoginAsync(tbLoginAtual, tbLoginNovo); tbUsuarioAtual = await usuarioBsn.AlterarUsuarioAsync(tbUsuarioAtual, tbUsuarioNovo); Models.Response.AlterarUsuarioResponse resp = usuarioCnv.ToAlterarUsuarioResponse(tbLoginAtual, tbUsuarioAtual); return(resp); } catch (Exception e) { return(BadRequest( new Models.Response.ErroResponse(400, e.Message) )); } }
public Models.Response.AlterarUsuarioResponse ToAlterarUsuarioResponse(Models.TbLogin tbLogin, Models.TbUsuario tbUsuario) { Models.Response.AlterarUsuarioResponse resp = new Models.Response.AlterarUsuarioResponse(); resp.Senha = tbLogin.DsSenha; resp.ReceberEmail = tbUsuario.BtReceberEmail; resp.NomeUsuario = tbUsuario.NmUsuario; resp.NomePerfil = tbUsuario.NmPerfil; resp.IdLogin = tbLogin.IdLogin; return(resp); }