public IActionResult Create([Bind("sNome,sSenha,sEmail,bAtivo,sTelefone,PaginaSelecionada")] Usuario _usuario, IFormFile sImagem) { if (ModelState.IsValid) { try { if (sImagem != null) { _usuario.sImagem = DateTime.Now.ToString("yyyyMMddHHmmss") + ".jpg"; Diverso.SaveImage(sImagem, "USUARIO", _usuario.sImagem); } _usuario.iCodUsuarioMovimentacao = HttpContext.Session.GetComplexData <Usuario>("UserData").ID; _usuarioRepository.Add(_usuario); _flashMessage.Confirmation("Operação realizada com sucesso!"); } catch (Exception) { _flashMessage.Danger("Erro ao realizar a operação!"); throw; } return(RedirectToAction(nameof(Index))); } ViewBag.Paginas = _usuarioPaginaRepository.Perfil(); return(View(_usuario)); }
public override void Update(Team obj) { if (obj.ATIVO) { foreach (var item in db.Teams.Where(p => p.IDPESSOA == obj.IDPESSOA && p.STATUS == true && p.ATIVO == true).ToList()) { db.Entry(item).State = EntityState.Modified; item.ATIVO = false; db.SaveChanges(); } } db.Entry(obj).State = EntityState.Modified; if (obj.SIMBOLO == null) { db.Entry(obj).Property("SIMBOLO").IsModified = false; } else { string sFoto = obj.ID + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".jpg"; Diverso.SaveCoverPicture(obj.FOTO, "Simbolo", sFoto); obj.SIMBOLO = sFoto; } db.Entry(obj).Property("DATACADASTRO").IsModified = false; db.Entry(obj).Property("STATUS").IsModified = false; obj.FOTO = "semimagem.png"; db.SaveChanges(); }
public override void Add(Team obj) { if (obj.ATIVO) { foreach (var item in db.Teams.Where(p => p.IDPESSOA == obj.IDPESSOA && p.STATUS == true && p.ATIVO == true).ToList()) { db.Entry(item).State = EntityState.Modified; item.ATIVO = false; db.SaveChanges(); } } if (obj.SIMBOLO == null) { obj.SIMBOLO = "semimagem.png"; } else { string sFoto = obj.ID + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".jpg"; Diverso.SaveCoverPicture(obj.FOTO, "FotoJogador", sFoto); obj.SIMBOLO = sFoto; } obj.FOTO = "semimagem.png"; db.Add(obj); db.SaveChanges(); }
public IActionResult Create([Bind("sNumero,sNome,dVencimento,sImagem,IdTipo,IdTipoEquipamento,IdTipoServico")] Contrato _contrato, IFormFile sImagem) { if (ModelState.IsValid) { try { if (sImagem != null) { string[] aFoto = sImagem.FileName.Split('.'); _contrato.sImagem = DateTime.Now.ToString("yyyyMMddHHmmss") + "." + aFoto[aFoto.Count() - 1]; Diverso.SaveImage(sImagem, "CONTRATO", _contrato.sImagem); } _contrato.iCodUsuarioMovimentacao = HttpContext.Session.GetComplexData <Usuario>("UserData").ID; _contratoRepository.Add(_contrato); _flashMessage.Confirmation("Operação realizada com sucesso!"); } catch (Exception) { _flashMessage.Danger("Erro ao realizar a operação!"); throw; } return(RedirectToAction(nameof(Index))); } ViewBag.ListaTipo = _tipoRepository.GetAllTipoDrop(2); ViewBag.ListaTipoServico = _tipoRepository.GetAllTipoDrop(4); ViewBag.ListaTipoEquipamento = _tipoRepository.GetAllTipoDrop(5); return(View(_contrato)); }
public IActionResult Index() { if (!Diverso.Acesso(HttpContext.Session.GetComplexData <Usuario>("UserData"), 4)) { return(RedirectToAction("DeniedAccess", "Login")); } return(View(_contratoRepository.GetAll())); }
public IActionResult Create() { if (!Diverso.Acesso(HttpContext.Session.GetComplexData <Usuario>("UserData"), 3)) { return(RedirectToAction("DeniedAccess", "Login")); } ViewBag.ListaTipo = _tipoRepository.GetAllTipoDrop(3); return(View()); }
public IActionResult Create() { if (!Diverso.Acesso(HttpContext.Session.GetComplexData <Usuario>("UserData"), 1)) { return(RedirectToAction("DeniedAccess", "Login")); } ViewBag.Paginas = _usuarioPaginaRepository.Perfil(); return(View()); }
public Pessoa Authenticate(string email, string password) { var _pessoa = db.Pessoas.Include(x => x.PessoaPerfis).FirstOrDefault(x => x.EMAIL == email && x.SENHA == password); if (_pessoa == null) { return(null); } _pessoa.token = Diverso.GetBuildToken(_pessoa.EMAIL); return(_pessoa); }
public void Forgot(string sEmail) { string _body = ""; string strBody = ""; string sTitulo = ""; string sToken = Guid.NewGuid().ToString("D"); Usuario p = conn.Query <Usuario>("SELECT TOP(1) * FROM Usuario WHERE sEmail =@sEmail ", new { sEmail }).FirstOrDefault(); conn.Execute("UPDATE Usuario SET SECURITYSTAMP=@SECURITYSTAMP WHERE ID = @ID;", new { p.ID, SECURITYSTAMP = sToken }); var builder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json").Build(); string sSite = builder.GetSection(key: "AppConfiguration")["Url"]; _body += "<table style='border - collapse:collapse; border - spacing:0; Margin - left:auto; Margin - right:auto; width: 600px; background - color:#ffffff;font-size:14px;table-layout:fixed'><tbody><tr><td style='padding:0;vertical-align:top;text-align:left'><div><div style='font-size:32px;line-height:32px'> </div></div>"; _body += "<table style='border - collapse:collapse; border - spacing:0; table - layout:fixed; width: 100 % '><tbody><tr><td style='padding: 0; vertical - align:top; padding - left:32px; padding - right:32px; word -break:break-word; word - wrap:break-word'><h1 style='font - style:normal; font - weight:700; Margin - bottom:18px; Margin - top:0; font - size:36px; line - height:44px; font - family:Ubuntu,sans - serif; color:#565656;text-align:center'><strong style='font-weight:bold'>Mudança de Senha</strong></h1>"; _body += "</td></tr></tbody></table><table style='border - collapse:collapse; border - spacing:0; table - layout:fixed; width: 100 % '><tbody><tr><td style='padding: 0; vertical - align:top; padding - left:32px; padding - right:32px; word -break:break-word; word - wrap:break-word'><div style='min - height:20px'> </div></td></tr></tbody></table><table style='border - collapse:collapse; border - spacing:0; table - layout:fixed; width: 100 % '><tbody><tr><td style='padding: 0; vertical - align:top; padding - left:32px; padding - right:32px; word -break:break-word; word - wrap:break-word'><p style='font - style:normal; font - weight:400; Margin - bottom:24px; Margin - top:0; line - height:24px; font - family:Ubuntu,sans - serif; color:#787778;font-size:16px'>Segue o link para mudança de sua senha.</p></td></tr></tbody></table><table style='border-collapse:collapse;border-spacing:0;table-layout:fixed;width:100%'><tbody><tr><td style='padding:0;vertical-align:top;padding-left:1px;padding-right:32px;word-break:break-word;word-wrap:break-word'><div><u></u><a style='border-radius:3px;display:inline-block;font-size:14px;font-weight:700;line-height:24px;padding:13px 35px 12px 35px;text-align:center;text-decoration:none!important;color:#fff;font-family:Ubuntu,sans-serif;background-color:#a42532' href=\"{1}\" target='_blank'>Clique aqui</a><u></u></div></td></tr></tbody></table><table style='border-collapse:collapse;border-spacing:0;table-layout:fixed;width:100%'><tbody><tr><td style='padding:0;vertical-align:top;padding-left:1px;padding-right:32px;word-break:break-word;word-wrap:break-word'><div style='min-height:14px'> </div></td></tr></tbody></table><table style='border-collapse:collapse;border-spacing:0;table-layout:fixed;width:100%'><tbody><tr><td style='padding:0;vertical-align:top;padding-left:1px;padding-right:32px;word-break:break-word;word-wrap:break-word'><p style='font-style:normal;font-weight:400;Margin-bottom:0;Margin-top:0;line-height:24px;font-family:Ubuntu,sans-serif;color:#787778;font-size:16px'><em>Equipe </em>LabLuz agradece sua preferência.</p></td></tr></tbody></table><div style='font-size:32px;line-height:32px'> </div></td></tr></tbody></table>"; strBody = ""; strBody = strBody + "<html>"; strBody = strBody + "<head>"; strBody = strBody + "<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>"; strBody = strBody + "<title>Untitled Document</title>"; strBody = strBody + "</head>"; strBody = strBody + "<body>"; strBody = strBody + "<table style='font-family: verdana; font-size: 11px; color: #000000;' width='100%'>"; strBody = strBody + "<tr align=center><td colspan=2><img src='cid:Imagem1' /></td></tr>"; strBody = strBody + "<tr align=center><td colspan=2></td></tr>"; strBody = strBody + "<tr><td font-weight:bold'><p><p></td></tr> "; strBody = strBody + string.Format(_body, p.sNome, sSite + @"Login/ResetPassword?Token=" + sToken + "&Email=" + p.sEmail); strBody = strBody + "</table> "; strBody = strBody + "<br><br>"; strBody = strBody + "Esta é uma mensagem automática enviada pelo sistema. Não precisa responder."; strBody = strBody + "</body>"; strBody = strBody + "</html>"; sTitulo = "Esqueci minha senha"; Diverso.SendEmail(sEmail, sTitulo, strBody, null); }
public override void Add(Player obj) { if (obj.FOTO == null) { obj.FOTO = "semimagem.png"; } else { string sFoto = obj.ID + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".jpg"; Diverso.SaveCoverPicture(obj.FOTO, "FotoJogador", sFoto); obj.FOTO = sFoto; } db.Add(obj); db.SaveChanges(); }
public IActionResult EditUser(int id, [Bind("ID,sNome,sSenha,sEmail,sTelefone")] Usuario _usuario, IFormFile sImagem) { if (id != _usuario.ID) { return(NotFound()); } if (ModelState.IsValid) { try { if (sImagem != null) { _usuario.sImagem = DateTime.Now.ToString("yyyyMMddHHmmss") + ".jpg"; Diverso.SaveImage(sImagem, "USUARIO", _usuario.sImagem); } _usuario.iCodUsuarioMovimentacao = Convert.ToInt16(HttpContext.Session.GetString("ID")); _usuarioRepository.UpdateUser(_usuario); HttpContext.Session.SetComplexData("UserData", _usuarioRepository.GetByIdUsuarioPerfil(_usuario.ID)); _flashMessage.Confirmation("Operação realizada com sucesso!"); } catch (DbUpdateConcurrencyException) { _flashMessage.Danger("Erro ao realizar a operação!"); if (!UsuarioExists(_usuario.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(EditUser))); } return(View(_usuario)); }
public IActionResult Edit(int id, [Bind("ID,sNumero,sNome,dVencimento,dServico,IdTipo")] Certificado _certificado, IFormFile sImagem) { if (id != _certificado.ID) { return(NotFound()); } if (ModelState.IsValid) { try { if (sImagem != null) { string[] aFoto = sImagem.FileName.Split('.'); _certificado.sImagem = DateTime.Now.ToString("yyyyMMddHHmmss") + "." + aFoto[aFoto.Count() - 1]; Diverso.SaveImage(sImagem, "CERTIFICADO", _certificado.sImagem); } _certificado.iCodUsuarioMovimentacao = HttpContext.Session.GetComplexData <Usuario>("UserData").ID; _certificadoRepository.Update(_certificado); _flashMessage.Confirmation("Operação realizada com sucesso!"); } catch (DbUpdateConcurrencyException) { _flashMessage.Danger("Erro ao realizar a operação!"); if (!CertificadoExists(_certificado.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewBag.ListaTipo = _tipoRepository.GetAllTipoDrop(3); return(View(_certificado)); }
public async Task <IActionResult> Download(string sImagem) { if (sImagem == null) { _flashMessage.Warning("Arquivo não encontrado!"); return(RedirectToAction(nameof(Index))); } string path = Diverso.Download(sImagem, "CONTRATO"); var memory = new MemoryStream(); using (var stream = new FileStream(path, FileMode.Open)) { await stream.CopyToAsync(memory); } memory.Position = 0; return(File(memory, Diverso.GetContentType(path), Path.GetFileName(path))); }
public IActionResult Delete(int?id) { if (!Diverso.Acesso(HttpContext.Session.GetComplexData <Usuario>("UserData"), 4)) { return(RedirectToAction("DeniedAccess", "Login")); } //Delete if (id == null) { return(NotFound()); } var _documento = _contratoRepository.GetById(id); if (_documento == null) { return(NotFound()); } return(View(_documento)); }
public IActionResult Edit(int?id) { if (!Diverso.Acesso(HttpContext.Session.GetComplexData <Usuario>("UserData"), 2)) { return(RedirectToAction("DeniedAccess", "Login")); } if (id == null) { return(NotFound()); } var _documento = _documentoRepository.GetById(id); if (_documento == null) { return(NotFound()); } ViewBag.ListaTipo = _tipoRepository.GetAllTipoDrop(1); return(View(_documento)); }
public IActionResult Edit(int?id) { if (!Diverso.Acesso(HttpContext.Session.GetComplexData <Usuario>("UserData"), 1)) { return(RedirectToAction("DeniedAccess", "Login")); } if (id == null) { return(NotFound()); } var _usuario = _usuarioRepository.GetByIdUsuarioPerfil(id); if (_usuario == null) { return(NotFound()); } ViewBag.Paginas = _usuarioPaginaRepository.Perfil(_usuario.ID); return(View(_usuario)); }
public override void Update(Player obj) { db.Entry(obj).State = EntityState.Modified; if (obj.FOTO == null) { db.Entry(obj).Property("FOTO").IsModified = false; } else { string sFoto = obj.ID + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".jpg"; Diverso.SaveCoverPicture(obj.FOTO, "FotoJogador", sFoto); obj.FOTO = sFoto; } db.Entry(obj).Property("DATACADASTRO").IsModified = false; db.Entry(obj).Property("DATADISPENSA").IsModified = false; db.Entry(obj).Property("STATUS").IsModified = false; db.SaveChanges(); }
public void SendEmail(string sEmail) { string _body, strBody, conteudo; string sTitulo = ""; int Count = 0; CertificadoRepository certificadoRepository = new CertificadoRepository(); ContratoRepository contratoRepository = new ContratoRepository(); DocumentoRepository documentoRepository = new DocumentoRepository(); conteudo = ""; foreach (Certificado item in certificadoRepository.GetAllVencidos()) { conteudo += "<tr><td font-weight:bold'><b>Certificado: </b>" + item.sNome + "</td></tr>"; Count = Count + 1; } foreach (Contrato item in contratoRepository.GetAllVencidos()) { conteudo += "<tr><td font-weight:bold'><b>Contrato: </b>" + item.sNome + "</td></tr>"; Count = Count + 1; } foreach (Documento item in documentoRepository.GetAllVencidos()) { conteudo += "<tr><td font-weight:bold'><b>Documeto: </b>" + item.sNome + "</td></tr>"; Count = Count + 1; } _body = "<table style='border - collapse:collapse; border - spacing:0; Margin - left:auto; Margin - right:auto; width: 600px; background - color:#ffffff;font-size:14px;table-layout:fixed'><tbody><tr><td style='padding:0;vertical-align:top;text-align:left'><div><div style='font-size:32px;line-height:32px'> </div></div>"; _body += "<table style='border - collapse:collapse; border - spacing:0; table - layout:fixed; width: 100 % '><tbody><tr><td style='padding: 0; vertical - align:top; padding - left:32px; padding - right:32px; word -break:break-word; word - wrap:break-word'><h1 style='font - style:normal; font - weight:700; Margin - bottom:18px; Margin - top:0; font - size:36px; line - height:44px; font - family:Ubuntu,sans - serif; color:#565656;text-align:center'><strong style='font-weight:bold'>Aviso de Vencimento</strong></h1>"; _body += "</td></tr></tbody></table><table style='border - collapse:collapse; border - spacing:0; table - layout:fixed; width: 100 % '><tbody><tr><td style='padding: 0; vertical - align:top; padding - left:32px; padding - right:32px; word -break:break-word; word - wrap:break-word'><div style='min - height:20px'> </div>" + conteudo + "</td></tr></tbody></table><table style='border-collapse:collapse;border-spacing:0;table-layout:fixed;width:100%'><tbody><tr><td style='padding:0;vertical-align:top;padding-left:1px;padding-right:32px;word-break:break-word;word-wrap:break-word'><div><u></u></div></td></tr></tbody></table><table style='border-collapse:collapse;border-spacing:0;table-layout:fixed;width:100%'><tbody><tr><td style='padding:0;vertical-align:top;padding-left:1px;padding-right:32px;word-break:break-word;word-wrap:break-word'><div style='min-height:14px'> </div></td></tr></tbody></table><table style='border-collapse:collapse;border-spacing:0;table-layout:fixed;width:100%'><tbody><tr><td style='padding:0;vertical-align:top;padding-left:1px;padding-right:32px;word-break:break-word;word-wrap:break-word'><p style='font-style:normal;font-weight:400;Margin-bottom:0;Margin-top:0;line-height:24px;font-family:Ubuntu,sans-serif;color:#787778;font-size:16px'><em>Equipe </em>LabLuz agradece sua preferência.</p></td></tr></tbody></table><div style='font-size:32px;line-height:32px'> </div></td></tr></tbody></table>"; strBody = ""; strBody = strBody + "<html>"; strBody = strBody + "<head>"; strBody = strBody + "<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>"; strBody = strBody + "<title>Untitled Document</title>"; strBody = strBody + "</head>"; strBody = strBody + "<body>"; strBody = strBody + "<table style='font-family: verdana; font-size: 11px; color: #000000;' width='100%'>"; strBody = strBody + "<tr align=center><td colspan=2><img src='cid:Imagem1' /></td></tr>"; strBody = strBody + "<tr align=center><td colspan=2></td></tr>"; strBody = strBody + "<tr><td font-weight:bold'><p><p></td></tr> "; strBody = strBody + _body; strBody = strBody + "</table> "; strBody = strBody + "<br><br>"; strBody = strBody + "Esta é uma mensagem automática enviada pelo sistema. Não precisa responder."; strBody = strBody + "</body>"; strBody = strBody + "</html>"; sTitulo = "Alerta de vencimentos"; if (Count > 0) { Diverso.SendEmail(sEmail, sTitulo, strBody, null); } }
public void UpdateSenha(string SECURITYSTAMP, string sSenha) { sSenha = Diverso.GenerateMD5(sSenha); conn.Execute("UPDATE Usuario SET sSenha=@sSenha WHERE SECURITYSTAMP=@SECURITYSTAMP; ", new { sSenha, SECURITYSTAMP }); }