public static EmpresaCadastro GetUsuarioEmpresa() { string _login = HttpContext.Current.User.Identity.Name; //if (HttpContext.Current.Request.Cookies.Count > 0 || HttpContext.Current.Request.Cookies["Usuario"] != null) if (HttpContext.Current.Session.Count > 0 || HttpContext.Current.Session["Usuario"] != null) { _login = HttpContext.Current.Session["Usuario"].ToString(); //_login = HttpContext.Current.Request.Cookies["Usuario"].Value.ToString(); if (_login == "") { return(null); } else { Context _db = new Context(); EmpresaCadastro empresaCadastro = (from e in _db.EmpresaCadastros where e.Email == _login select e).SingleOrDefault(); return(empresaCadastro); } } else { return(null); } }
public ActionResult DeleteConfirmed(int id) { EmpresaCadastro empresaCadastro = db.EmpresaCadastros.Find(id); db.EmpresaCadastros.Remove(empresaCadastro); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult ValidarHash([Bind(Include = "EmpresaCadastroID,Nome,Email,Senha,RazaoSocial,QtdFuncionario,Cep,Rua,Bairro,Numero,Complemento,Cidade,Estado,Logomarca,Objetivo,Hash,SegmentacaoID")] EmpresaCadastro empresaCadastro, HttpPostedFileBase logomarca) { if (ModelState.IsValid) { db.Entry(empresaCadastro).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Logar")); } ViewBag.Message = "Link inválido, entre em contato com a StarToUp"; return(View()); }
// GET: api/EmpresaAPI/5 public EmpresaCadastro Get(int id) { var RNEmpresas = new ZAdmin_RN.Empresas.Empresas(); var resultado = RNEmpresas.retornaEmpresa(id); var cadEmpresa = new EmpresaCadastro(); cadEmpresa.Empresa = resultado; cadEmpresa.Setores = RNEmpresas.RetornaSetores(); return(cadEmpresa); }
// GET: EmpresaCadastros/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } EmpresaCadastro empresaCadastro = db.EmpresaCadastros.Find(id); if (empresaCadastro == null) { return(HttpNotFound()); } return(View(empresaCadastro)); }
// GET: EmpresaCadastros/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } EmpresaCadastro empresaCadastro = db.EmpresaCadastros.Find(id); if (empresaCadastro == null) { return(HttpNotFound()); } ViewBag.SegmentacaoID = new SelectList(db.Segmentacoes, "SegmentacaoID", "Descricao", empresaCadastro.SegmentacaoID); return(View(empresaCadastro)); }
public ActionResult Edit([Bind(Include = "EmpresaCadastroID,Nome,Email,Senha,RazaoSocial,QtdFuncionario,Cep,Rua,Bairro,Numero,Complemento,Cidade,Estado,Logomarca,Objetivo,LinkInstagram,LinkFacebook,LinkLinkedin,TermoUso,Hash,SegmentacaoID")] EmpresaCadastro empresaCadastro, HttpPostedFileBase logomarca) { ViewBag.FotoMensagem = ""; try { if (ModelState.IsValid) { string fileName = ""; string contentType = ""; string path = ""; EmpresaCadastro empresaCadastroBD = db.EmpresaCadastros.Find(empresaCadastro.EmpresaCadastroID); if (logomarca != null && logomarca.ContentLength > 0) { fileName = System.IO.Path.GetFileName(logomarca.FileName); contentType = logomarca.ContentType; path = System.Configuration.ConfigurationManager.AppSettings["PathFiles"] + "\\PerfilEmpresa\\" + fileName; logomarca.SaveAs(path); empresaCadastro.Logomarca = fileName; } else { if (logomarca == null) { if (empresaCadastroBD.Logomarca != null) { if (empresaCadastroBD.Logomarca.Length > 0) { //usa valores que ja estao no BD empresaCadastro.Logomarca = empresaCadastroBD.Logomarca; } } } } ((IObjectContextAdapter)db).ObjectContext.Detach(empresaCadastroBD); db.Entry(empresaCadastro).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } } catch (Exception ex) { ViewBag.FotoMensagem = "Não foi possível salvar a foto"; } ViewBag.SegmentacaoID = new SelectList(db.Segmentacoes, "SegmentacaoID", "Descricao", empresaCadastro.SegmentacaoID); return(View(empresaCadastro)); }
public ActionResult ValidarHash(string h) { if (h == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } EmpresaCadastro s = db.EmpresaCadastros.Where(e => e.Hash == h).ToList().SingleOrDefault(); int id = s.EmpresaCadastroID; EmpresaCadastro empresaCadastro = db.EmpresaCadastros.Find(id); if (empresaCadastro == null) { return(HttpNotFound()); } ViewBag.SegmentacaoID = new SelectList(db.Segmentacoes, "SegmentacaoID", "Descricao", empresaCadastro.SegmentacaoID); return(View(empresaCadastro)); }
public ActionResult EsqueciSenha([Bind(Include = "StartupCadastroID,Nome,Email,Senha,Cep,Rua,Bairro,Numero,Complemento,Cidade,Estado,Sobre,Objetivo,DataFundacao,TamanhoTime,Logotipo,ImagemLocal1,ImagemLocal2,ImagemMVP1,ImagemMVP2,ImagemMVP3,ImagemMVP4,Hash,SegmentacaoID")] StartupCadastro empresaCadastro, HttpPostedFileBase logoTipo, HttpPostedFileBase imagemLocal1, HttpPostedFileBase imagemLocal2, HttpPostedFileBase imagemMVP1, HttpPostedFileBase imagemMVP2, HttpPostedFileBase imagemMVP3, HttpPostedFileBase imagemMVP4) { EmpresaCadastro e = db.EmpresaCadastros.Where(s => s.Email == empresaCadastro.Email).ToList().SingleOrDefault(); string hash = (e.Email + e.Numero); e.Hash = hash; ((IObjectContextAdapter)db).ObjectContext.Detach(e); db.Entry(e).State = EntityState.Modified; db.SaveChanges(); GmailEmailService gmail = new GmailEmailService(); EmailMessage msg = new EmailMessage(); msg.Body = "<!DOCTYPE HTML><html><body><p>Olá!</p><p>Clique no link abaixo para redefinir senha:<br/><a href= http://localhost:50072/LogonEmpresa/ValidarHash?h=" + hash + ">Redefinir Senha</a></p><p>Aconselhamos que por segurança você altere sua senha para uma mais forte!</p><p>Atenciosamente,<br/>StarToUp.</p></body></html>"; msg.IsHtml = true; msg.Subject = "Redefinir Senha - StarToUp"; msg.ToEmail = empresaCadastro.Email; gmail.SendEmailMessage(msg); return(View()); }
public ActionResult Create([Bind(Include = "EmpresaCadastroID,Nome,Email,Senha,RazaoSocial,QtdFuncionario,Cep,Rua,Bairro,Numero,Complemento,Cidade,Estado,Logomarca,Objetivo,LinkInstagram,LinkFacebook,LinkLinkedin,TermoUso,Hash,SegmentacaoID")] EmpresaCadastro empresaCadastro, HttpPostedFileBase logomarca) { ViewBag.FotoMensagem = ""; try { if (ModelState.IsValid && empresaCadastro.TermoUso == true) { string fileName = ""; string contentType = ""; string path = ""; if (logomarca != null && logomarca.ContentLength > 0) { fileName = System.IO.Path.GetFileName(logomarca.FileName); contentType = logomarca.ContentType; path = System.Configuration.ConfigurationManager.AppSettings["PathFiles"] + "\\PerfilEmpresa\\" + fileName; logomarca.SaveAs(path); empresaCadastro.Logomarca = fileName; } db.EmpresaCadastros.Add(empresaCadastro); db.SaveChanges(); GmailEmailService gmail = new GmailEmailService(); EmailMessage msg = new EmailMessage(); msg.Body = "<!DOCTYPE HTML><html><body><p>" + empresaCadastro.Nome + ",<br/>Seja bem-vinda(o)!</p><p>Sua decolagem está prestes a iniciar!<br/>Clique no link abaixo para finalizar seu cadastro:</p><a href= http://localhost:50072/LogonEmpresa/Logar/" + "> Faça seu login aqui!</a><p>Esperamos que você decole com a gente!</p><p>Atenciosamente,<br/>StarToUp.</p></body></html>"; msg.IsHtml = true; msg.Subject = "E-mail de Confirmação - StarToUp"; msg.ToEmail = empresaCadastro.Email; gmail.SendEmailMessage(msg); var response = Request["g-recaptcha-response"]; //chave secreta que foi gerada no site const string secret = "6Ldjv5gUAAAAAE8AgNayyITU99Lexs-BEeZU4imx"; var client = new WebClient(); var reply = client.DownloadString( string.Format("https://www.google.com/recaptcha/api/siteverify?secret={0}&response={1}", secret, response)); var captchaResponse = JsonConvert.DeserializeObject <CaptchaResponse>(reply); //Response false – devemos ver qual a mensagem de erro if (!captchaResponse.Success) { if (captchaResponse.ErrorCodes.Count <= 0) { return(View()); } var error = captchaResponse.ErrorCodes[0].ToLower(); switch (error) { case ("missing-input-secret"): ViewBag.Message = "The secret parameter is missing."; break; case ("invalid-input-secret"): ViewBag.Message = "The secret parameter is invalid or malformed."; break; case ("missing-input-response"): ViewBag.Message = "The response parameter is missing."; break; case ("invalid-input-response"): ViewBag.Message = "The response parameter is invalid or malformed."; break; default: ViewBag.Message = "Error occured. Please try again"; break; } return(View()); } else { ViewBag.Message = "Valid"; return(RedirectToAction("../Home/Principal")); } } } catch (Exception ex) { ViewBag.FotoMensagem = "Não foi possível salvar a foto"; } ViewBag.SegmentacaoID = new SelectList(db.Segmentacoes, "SegmentacaoID", "Descricao", empresaCadastro.SegmentacaoID); ViewBag.StartupCadastroID = new SelectList(db.StartupCadastros, "StartupCadastroID", "Nome", empresaCadastro.EmpresaCadastroID); return(View(empresaCadastro)); }