public ActionResult Index(UsuarioLoginModel model) { if (ModelState.IsValid) { try { Criptografia c = new Criptografia(); UsuarioRep rep = new UsuarioRep(); Usuario u = rep.FindByNamePass(model.Login, c.ToEncrypt(model.Senha)); if (u != null) { FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(u.Nome, false, 5); HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(ticket)); Response.Cookies.Add(cookie); Session["usuario"] = u; return(RedirectToAction("Index", "Logged")); } else { ViewBag.Mensagem = "Acesso Negado."; } } catch (Exception e) { ViewBag.Mensagem = e.Message; } } return(View()); }
public ActionResult Edicao(TarefaEdicaoModel model) { if (ModelState.IsValid) { try { UsuarioRep repUsuario = new UsuarioRep(); Tarefa t = new Tarefa(); t.Usuario = repUsuario.FindByName(User.Identity.Name); t.IdTarefa = model.IdTarefa; t.Titulo = model.Titulo; t.Descricao = model.Descricao; t.Usuario.IdUsuario = model.IdUsuario; TarefaRep rep = new TarefaRep(); rep.Update(t); ViewBag.Mensagem = "Atualizado com sucesso."; ModelState.Clear(); //Aqui eu limpo os campos do formulário } catch (Exception e) { ViewBag.Mensagem = e.Message; } } return(View()); }
public Usuario GetId([FromUri] Int32 Id) { using (var db = new UsuarioRep()) { return(db.Get(Id)); } }
public ActionResult Excluir(TarefaExclusaoModel model) { if (ModelState.IsValid) { try { UsuarioRep repUsuario = new UsuarioRep(); Tarefa t = new Tarefa(); t.Usuario = repUsuario.FindByName(User.Identity.Name); t.IdTarefa = model.IdTarefa; t.Titulo = model.Titulo; t.Descricao = model.Descricao; TarefaRep rep = new TarefaRep(); rep.Delete(t); ModelState.Clear(); } catch (Exception e) { ViewBag.Mensagem = e.Message; } } return(View()); }
public ActionResult Index() { List <ConsultaTarefaModel> lista = new List <ConsultaTarefaModel>(); try { TarefaRep rep = new TarefaRep(); foreach (Tarefa t in rep.FindAll()) { ConsultaTarefaModel model = new ConsultaTarefaModel(); UsuarioRep repUsuario = new UsuarioRep(); t.Usuario = new Usuario(); t.Usuario = repUsuario.FindByName(User.Identity.Name); model.IdTarefa = t.IdTarefa; model.Titulo = t.Titulo; model.Descricao = t.Descricao; lista.Add(model); } } catch (Exception e) { ViewBag.Mensagem = e.Message; } return(View(lista)); }
public ActionResult Cadastro(TarefaCadastroModel model) { if (ModelState.IsValid) { try { UsuarioRep repUsuario = new UsuarioRep(); Tarefa t = new Tarefa(); t.Usuario = repUsuario.FindByName(User.Identity.Name); t.Titulo = model.Titulo; t.Descricao = model.Descricao; TarefaRep rep = new TarefaRep(); rep.Insert(t); ViewBag.Mensagem = "Tarefa Cadastrada com sucesso."; ModelState.Clear(); } catch (Exception e) { ViewBag.Mensagem = e.Message; } return(View(model)); } return(View()); }
//GET: Tarefa/Edicao public ActionResult Edicao() { TarefaEdicaoModel model = new TarefaEdicaoModel(); try { UsuarioRep repUsuario = new UsuarioRep(); Tarefa t = new Tarefa(); t.Usuario = repUsuario.FindByName(User.Identity.Name); int idTarefa = int.Parse(Request.QueryString["id"]); model.IdTarefa = t.IdTarefa; model.Titulo = t.Titulo; model.Descricao = t.Descricao; model.IdUsuario = t.Usuario.IdUsuario; TarefaRep rep = new TarefaRep(); rep.Update(t); ViewBag.Mensagem = "Tarefa atualizada com sucesso."; } catch (Exception e) { ViewBag.Mensagem = e.Message; } return(View(model)); }
private void btn_Cadastrar_Click_1(object sender, EventArgs e) { if (String.IsNullOrEmpty(txtNome.Text)) { MessageBox.Show("Digite o nome"); return; } if (String.IsNullOrEmpty(txtEmail.Text)) { MessageBox.Show("Digite o email"); return; } if (String.IsNullOrEmpty(txtSenha.Text)) { MessageBox.Show("Digite a senha"); return; } var usuario = new Model.Usuario { Nome = txtNome.Text, Email = txtEmail.Text, Senha = txtSenha.Text }; var rep = new UsuarioRep(); var isSalvo = rep.Inserir(usuario); if (isSalvo) { MessageBox.Show("Usuário salvo"); Close(); } else { MessageBox.Show("Problema ao salvar usuário"); } }
public IEnumerable <Usuario> Get() { using (var dbUsuario = new UsuarioRep()) { return(dbUsuario.GetAll().ToList()); } }
public DtoLogin Login([FromBody] dtoAuthentication dto) { using (var db = new UsuarioRep()) { return(db.Login(dto.nome, dto.senha)); } }
public Usuario fazerLogin(int ra) { Usuario usuario; usuario = new UsuarioRep().BuscarPorId(ra); return usuario; }
public void excluirUsuario(int ra) { var usuario = new UsuarioRep().BuscarPorId(ra); usuario.ativo = false; new UsuarioRep().Atualizar(usuario); }
public void Delete([FromUri] int id) { if (id != 0) { using (var dbCliente = new UsuarioRep()) { dbCliente.Delete(id); } } }
public void Put([FromBody] Usuario usuario) { if (usuario != null) { using (var dbCliente = new UsuarioRep()) { dbCliente.Update(usuario); } } }
public void Post([FromBody] Usuario usuario) { if (usuario != null) { using (var dbUsuario = new UsuarioRep()) { dbUsuario.Insert(usuario); } } }
public ICollection<Usuario> buscaEmailUsuario(string email) { ICollection<Usuario> emailUsuarios = null; if (email != null) { emailUsuarios = new UsuarioRep().BuscarPorEmail(email); } return emailUsuarios; }
public ICollection<Usuario> buscaNomeUsuario(string nome) { ICollection<Usuario> nomeUsuarios = null; if (nome != null) { nomeUsuarios = new UsuarioRep().BuscarPorNome(nome); } return nomeUsuarios; }
private void btnLogin_Click(object sender, System.EventArgs e) { var rep = new UsuarioRep(); var usuario = rep.Login(txtEmail.Text, txtSenha.Text); //var usuario = rep.LoginSeguro(txtEmail.Text, txtSenha.Text); if (usuario != null) { Session.Instance.IdUsuario = usuario.Id; Session.Instance.NomeUsuario = usuario.Nome; Session.Instance.EmailUsuario = usuario.Email; DialogResult = DialogResult.OK; Close(); } else { MessageBox.Show(@"Acesso negado"); } }
public ActionResult Cadastro(UsuarioCadastroModel model) { try { if (ModelState.IsValid) { if (model.Senha.Equals(model.SenhaConfirm)) { UsuarioRep rep = new UsuarioRep(); if (!rep.HasName(model.Nome)) { Criptografia c = new Criptografia(); Usuario u = new Usuario(); u.Permissao = new Permissao(); u.Nome = model.Nome; u.Email = model.Email; u.Senha = c.ToEncrypt(model.Senha); u.Permissao.IdPermissao = model.IdPermissao; rep.Insert(u); ViewBag.Mensagem = "Usuario cadastrado com sucesso!"; ModelState.Clear(); } else { ViewBag.Mensagem = "Este usuário já existe! Favor, criar outro..."; } } else { ViewBag.Mensagem = "Senhas não conferem."; } } } catch (Exception e) { ViewBag.Mensagem = e.Message; } return(View(CarregarModelCadastro())); }
public void UpdateEmpresa(DtoEmpresa dtoempresa) { try { using (TransactionScope tscope = new TransactionScope()) { var usuario = new Models.Usuario(); var empresa = new Models.Empresa(); usuario.id = dtoempresa.id_usuario; usuario.nome = dtoempresa.nome; usuario.email = dtoempresa.email; usuario.senha = dtoempresa.senha; usuario.id_grupo = dtoempresa.id_grupo; using (var db = new UsuarioRep()) { db.Update(usuario); } empresa.id = dtoempresa.id; empresa.nome = dtoempresa.nome; empresa.ramo = dtoempresa.ramo; empresa.razao = dtoempresa.razao; empresa.cidade = dtoempresa.cidade; empresa.id_usuario = dtoempresa.id_usuario; using (var db = new EmpresaRep()) { db.Update(empresa); } tscope.Complete(); } } catch (Exception e) { throw new Exception("Erro ao gravar dados!"); } }
public void UpdateEmpresa(Models.Usuario usuario, Models.Empresa empresa) { try { using (TransactionScope tscope = new TransactionScope()) { using (var db = new UsuarioRep()) { db.Update(usuario); } using (var db = new EmpresaRep()) { db.Update(empresa); } tscope.Complete(); } } catch (Exception e) { throw new Exception("Erro ao gravar dados!"); } }
public ICollection<Usuario> listarLogin() { ICollection<Usuario> usuarios = new UsuarioRep().BuscarTodos(); return usuarios; }
static void Main(string[] args) { //Cadastra Turma var turma = new Turma { nome = "4A", ativo = true }; var turmaRep = new TurmaRep(); turma = turmaRep.Adicionar(turma); //Cadastra Semestre var semestre = new Semestre { nome = "4º Semestre", ativo = true }; var semestreRep = new SemestreRep(); semestre = semestreRep.Adicionar(semestre); //Cadastra Grupo var grupo = new Grupo { nome = "Smart.NET", ativo = true }; var grupoRep = new GrupoRep(); grupo = grupoRep.Adicionar(grupo); //Cadastra Curso var curso = new Curso { nome = "ADS - Análise e Desenvolvimentos de Sistemas", ativo = true }; var cursoRep = new CursoRep(); curso = cursoRep.Adicionar(curso); //Cadastra um Aluno var aluno = new Aluno { nome = "Eliseu", RA = 1410139, senha = "123", email = "*****@*****.**", perfil = Usuario.Perfil.Usuario, ativo = true, grupoId = grupo.grupoId }; var alunoRep = new AlunoRep(); aluno = alunoRep.Adicionar(aluno); //Cadastra um Professor var professor = new Professor { nome = "Vanderson", RA = 1400000, senha = "123", email = "*****@*****.**", perfil = Usuario.Perfil.Administrador, ativo = true }; var professorRep = new ProfessorRep(); professor = professorRep.Adicionar(professor); //Cadastra um Projeto var projeto = new Projeto { titulo = "4U - Sistema Gerenciador de Vendas Diretas", empresa = "Mary Kay", descricao = "Projeto para a empresa .....", urlSistema = "http://4u.com", cursoId = curso.cursoId, grupoId = grupo.grupoId, ativo = true, }; var projetoRep = new ProjetoRep(); projeto = projetoRep.Adicionar(projeto); //Adicionar uma fase ao projeto var fase = new Fase() { projetoId = projeto.projetoId, semestreId = semestre.semestreId, turmaId = turma.turmaId }; var faseRep = new FaseRep(); fase = faseRep.Adicionar(fase); //Adicionar agendamento à fase do projeto var agendamento = new Agendamento { assunto = "Reunião de último encontro da OPE", data = DateTime.Parse("05/12/2015"), horario = TimeSpan.Parse("08:30"), faseId = fase.faseId }; var agendamentoRep = new AgendamentoRep(); agendamento = agendamentoRep.Adicionar(agendamento); //Adicionar Convidado var convidado1 = new UsuarioRep().BuscarPorId(1410139); var convidado2 = new UsuarioRep().BuscarPorId(1400000); agendamento.convidados.Add(convidado1); agendamento.convidados.Add(convidado2); agendamentoRep.Atualizar(agendamento); //Adicionar Comentários var comentario1 = new Comentario { comentario = "Comentário de teste 1", data = DateTime.Now, RA = 1410139, agendamentoId = agendamento.agendamentoId }; var comentario2 = new Comentario { comentario = "Comentário de teste 2", data = DateTime.Now, RA = 1410139, agendamentoId = agendamento.agendamentoId }; var comentarioRep = new ComentarioRep(); comentarioRep.Adicionar(comentario1); comentarioRep.Adicionar(comentario2); ////Valida dados cadastrados //var agendamento = new AgendamentoRep().BuscarPorId(1);// //var aluno = new AlunoRep().BuscarPorId(1410139);// //var comentario = new ComentarioRep().BuscarPorId(1); //var curso = new CursoRep().BuscarPorId(1); //var fase = new FaseRep().BuscarPorId(1);// //var grupo = new GrupoRep().BuscarPorId(1); //var professor = new ProfessorRep().BuscarPorId(1400000);// //var projeto = new ProjetoRep().BuscarPorId(1);// //var semestre = new SemestreRep().BuscarPorId(1); //var turma = new TurmaRep().BuscarPorId(1); //var usuario = new UsuarioRep().BuscarPorId(1400000); }
public AppUsuario() { objUsuarioRep = new UsuarioRep(); }
public ActionResult CadastrarEntregador(CadastrarUsuarioViewModel usuario_) { CadastrarUsuarioViewModel vmUsuario = new CadastrarUsuarioViewModel(); if (!usuario_.AceitaTermos) TempData["AceitaTermos"] = "Aceite os Termos de Uso"; if (!ModelState.IsValid) return View(usuario_); UsuarioViewModel usuario = usuario_.Usuario; usuario.Password = Criptografia.getMD5Hash(usuario_.Usuario.Password); UsuarioDomain tempUsuario = new UsuarioRep().Register(Mapper.Map<UsuarioViewModel, UsuarioDomain>(usuario)); UsuarioRoleDomain usuariosRoles = new UsuarioRoleDomain(); usuariosRoles.UsuarioId = tempUsuario.Id; usuariosRoles.RoleId = new Guid("9C5DAEB3-1799-46D8-B82C-780DD17534AF"); new UsuarioRoleRep().Register(usuariosRoles); UsuarioRoleDomain usuariosRolesEntregador = new UsuarioRoleDomain(); usuariosRolesEntregador.UsuarioId = tempUsuario.Id; usuariosRolesEntregador.RoleId = new Guid("0115468A-DDE9-48C0-967A-528B83B75923"); new UsuarioRoleRep().Register(usuariosRoles); /* #region Enviar Email //Envia um e-mail para o usuário com os dados de acesso. var objEmail = new Email(ConfigurationManager.AppSettings["EmailConta"], ConfigurationManager.AppSettings["EmailSenhaConta"], ConfigurationManager.AppSettings["EmailRemetente"], ConfigurationManager.AppSettings["EmailServidorSmtp"]); string[] emailsCliente = { usuario_.Usuario.Email }; string[] parametersCliente = { "NOME", usuario_.Usuario.UserName, "DATACRIACAO",DateTime.Now.ToString(), }; objEmail.SendEmailTemplate("http://intrega.azurewebsites.net/TemplatesEmail/TemplateCadastroEntregador.html", emailsCliente, parametersCliente, "[Intrega] Finalize o seu cadastro no Intrega"); #endregion */ UsuarioViewModel user = Mapper.Map<UsuarioDomain, UsuarioViewModel>(new UsuarioRep().Authenticate(usuario_.Usuario.Email, Criptografia.getMD5Hash(usuario_.Usuario.Password))); if (user != null) { List<Claim> claims = GetClaims(user); //Get the claims from the headers or db or your user store if (null != claims) { SignIn(claims); return RedirectToAction("/Account/Entregador"); } } return View(); }