public bool SaveChanges(MusicoVM musico) { try { using (var db = new nosso_showEntities(Conexao.GetString())) { var u = db.usuario.Single(x => x.ID == musico.ID); var m = db.usuario_musico.SingleOrDefault(x => x.IDUsuario == musico.ID); u.Email = this.Email; u.Nascimento = this.Nascimento; u.Nome = this.Nome; u.Telefone = this.Telefone; u.Username = this.Username; if (m == null) { m = new usuario_musico { CPF = Regex.Replace(this.CPF, @"[^0-9]", string.Empty) }; } m.Descricao = this.Descricao; m.IDUsuario = u.ID; m.NomeArtistico = this.NomeArtistico; m.TipoUsuario = u.Tipo; this.SetJsonGeneros(u); this.SetJsonHabilidades(u); if (db.usuario_musico.Any(x => x.IDUsuario == u.ID)) { db.ObjectStateManager.ChangeObjectState(m, System.Data.EntityState.Modified); } else { db.usuario_musico.AddObject(m); } db.SaveChanges(); db.ObjectStateManager.ChangeObjectState(u, System.Data.EntityState.Modified); db.SaveChanges(); return(true); } } catch { } return(false); }
public ActionResult RedefinirSenha(string id, string Senha, string Confirmacao) { if (!string.IsNullOrEmpty(id)) { try { using (var db = new nosso_showEntities(Conexao.GetString())) { var requisicao = db.requisicao.Single(x => x.Hash == id && x.TipoRequisicao == 1 && x.Ativa); // 1 - Redefinir senha try { var u = requisicao.usuario; if (Senha == Confirmacao) { u.Senha = Criptografia.GetHash128(Senha); db.ObjectStateManager.ChangeObjectState(u, System.Data.EntityState.Modified); db.SaveChanges(); db.requisicao.DeleteObject(requisicao); db.SaveChanges(); ViewBag.Sucesso = "Sua senha foi alterada, efetue o acesso para continuar.";; } else { ViewBag.Mensagem = "As senhas informadas não coincidem."; } return(View(u)); } catch { ViewBag.Mensagem = "Sua requisição expirou ou é inválida."; } } } catch { ViewBag.Mensagem = "Não foi possível conectar ao servidor. Tente novamente em alguns minutos."; } } else { ViewBag.Mensagem = "Sua requisição expirou ou é inválida."; } return(Redirect("/entrar/")); }
public bool SaveChanges() { try { using (var db = new nosso_showEntities(Conexao.GetString())) { var u = db.usuario.Single(x => x.ID == this.Usuario.ID); var e = db.usuario_estabelecimento.SingleOrDefault(x => x.IDUsuario == this.Usuario.ID); u.Email = this.Email; u.Nome = this.Nome; u.Username = this.Username; if (e == null) { e = new usuario_estabelecimento(); } e.CNPJ = Regex.Replace(this.CNPJ, @"[^0-9]", string.Empty); e.De = this.De; e.Ate = this.Ate; e.Das = this.Das; e.As = this.As; e.Descricao = this.Descricao; e.IDAmbientacao = this.IDAmbientacao; e.IDUsuario = this.Usuario.ID; e.Razao = this.Razao; e.TipoUsuario = this.Usuario.Tipo; if (db.usuario_estabelecimento.Any(x => x.IDUsuario == u.ID)) { db.ObjectStateManager.ChangeObjectState(e, System.Data.EntityState.Modified); } else { db.usuario_estabelecimento.AddObject(e); } db.SaveChanges(); db.ObjectStateManager.ChangeObjectState(u, System.Data.EntityState.Modified); db.SaveChanges(); return(true); } } catch { return(false); } }
public ActionResult ConfirmarConta(string id) { try { using (var db = new nosso_showEntities(Conexao.GetString())) { var req = db.requisicao.SingleOrDefault(x => x.Hash == id && x.Ativa); if (req != null) { var u = req.usuario; u.Confirmado = true; req.Ativa = false; db.ObjectStateManager.ChangeObjectState(req, System.Data.EntityState.Modified); db.ObjectStateManager.ChangeObjectState(u, System.Data.EntityState.Modified); db.SaveChanges(); ViewBag.Nome = u.Username; return(View()); } } } catch { } return(Redirect("/entrar/")); }
public bool TogglePublicar() { try { using (var db = new nosso_showEntities(Conexao.GetString())) { var evento = db.evento.Single(x => x.ID == this.ID); if (evento.Publicado) { evento.Ativo = false; evento.Publicado = false; } else { evento.Ativo = true; evento.Publicado = true; } db.ObjectStateManager.ChangeObjectState(evento, System.Data.EntityState.Modified); db.SaveChanges(); return(true); } } catch { } return(false); }
public bool ToggleSeguirEvento(int idEvento) { try { using (var db = new nosso_showEntities(Conexao.GetString())) { var u = db.usuario.Single(x => x.ID == this.ID); var e = db.evento.Single(x => x.ID == idEvento); if (u.evento.Any(x => x.ID == idEvento)) { u.evento.Remove(e); } else { u.evento.Add(e); } db.ObjectStateManager.ChangeObjectState(u, System.Data.EntityState.Modified); db.SaveChanges(); return(true); } } catch { } return(false); }
public bool SaveChanges() { try { using (var db = new nosso_showEntities(Conexao.GetString())) { var data = DateTime.Now; var u = new usuario { Ativo = true, Confirmado = false, Cadastro = data, Email = this.Email, Username = this.Usuario, Nascimento = DateTime.MinValue, Nome = this.Nome, Senha = Criptografia.GetHash128(this.Senha), Telefone = string.Empty, Tipo = db.usuario_tipo.First(x => x.ID == this.Tipo).ID }; db.usuario.AddObject(u); db.SaveChanges(); var req = new Requisicao(u, 2); req.SaveChanges(); return(true); } } catch { return(false); } }
public bool ResponderConvite(int idEvento, bool confirmado) { try { using (var db = new nosso_showEntities(Conexao.GetString())) { var c = db.evento_musico.FirstOrDefault(x => x.IDEvento == idEvento && x.IDMusico == this.ID); if (confirmado) { c.Confirmado = true; c.Recusado = false; } else { c.Confirmado = false; c.Recusado = true; } db.ObjectStateManager.ChangeObjectState(c, System.Data.EntityState.Modified); db.SaveChanges(); new MensagemEmail().RespostaConvite(c); return(true); } } catch { } return(false); }
private void SetJsonHabilidades(usuario usuario) { try { using (var db = new nosso_showEntities(Conexao.GetString())) { var u = db.usuario.Single(x => x.ID == usuario.ID); var dbHabs = u.hab_musical.ToList(); for (int i = 0; i < dbHabs.Count; i++) { var hab = dbHabs[i]; u.hab_musical.Remove(hab); } var habIds = JsonConvert.DeserializeObject <List <int> >(this.JsonHabilidades); for (int i = 0; i < habIds.Count; i++) { var hab = habIds[i]; var dbHab = db.hab_musical.Single(x => x.ID == hab); u.hab_musical.Add(dbHab); } db.SaveChanges(); } } catch { } }
public static usuario Autenticar(string email, string senha, string sessao) { try { var usuario = GetUsuario(email, senha); using (var db = new nosso_showEntities(Conexao.GetString())) { var auth = new autenticacao { Data = DateTime.Now, IDUsuario = usuario.ID, IP = System.Web.HttpContext.Current.Request.UserHostAddress, Sessao = sessao, Tipo = usuario.Tipo }; db.autenticacao.AddObject(auth); db.SaveChanges(); } return(usuario); } catch { } return(null); }
private void SetJsonGeneros(usuario usuario) { try { using (var db = new nosso_showEntities(Conexao.GetString())) { var u = db.usuario.Single(x => x.ID == usuario.ID); var dbGens = u.genero_musical.ToList(); for (int i = 0; i < dbGens.Count; i++) { var gen = dbGens[i]; u.genero_musical.Remove(gen); } var genIds = JsonConvert.DeserializeObject <List <int> >(this.JsonGeneros); for (int i = 0; i < genIds.Count; i++) { var gen = genIds[i]; var dbGen = db.genero_musical.Single(x => x.ID == gen); u.genero_musical.Add(dbGen); } db.SaveChanges(); } } catch { } }
private void SetJsonAmbientes(usuario usuario) { try { using (var db = new nosso_showEntities(Conexao.GetString())) { var u = db.usuario.Single(x => x.ID == usuario.ID); var dbAmbs = u.ambientacao.ToList(); for (int i = 0; i < dbAmbs.Count; i++) { var amb = dbAmbs[i]; u.ambientacao.Remove(amb); } var ambIds = JsonConvert.DeserializeObject <List <int> >(this.JsonAmbientes); for (int i = 0; i < ambIds.Count; i++) { var amb = ambIds[i]; var dbAmb = db.ambientacao.Single(x => x.ID == amb); u.ambientacao.Add(dbAmb); } db.SaveChanges(); } } catch { } }
public bool SaveChanges() { try { using (var db = new nosso_showEntities(Conexao.GetString())) { var req = new requisicao { Ativa = true, Data = this.Mensagem.Data, Hash = this.Mensagem.Hash, IDUsuario = this.Usuario.ID, Vencimento = DateTime.Now.AddHours(1), TipoRequisicao = this.IDTipo, TipoUsuario = this.Usuario.Tipo }; db.requisicao.AddObject(req); db.SaveChanges(); if (EnviarMensagem(req)) { return(true); } } } catch { } return(false); }
public bool SaveChanges(UsuarioVM usuario) { try { using (var db = new nosso_showEntities(Conexao.GetString())) { var u = db.usuario.Single(x => x.ID == usuario.ID); u.Email = this.Email; u.Nascimento = this.Nascimento; u.Nome = this.Nome; u.Telefone = this.Telefone; u.Username = this.Username; this.SetJsonAmbientes(u); this.SetJsonGeneros(u); db.ObjectStateManager.ChangeObjectState(u, System.Data.EntityState.Modified); db.SaveChanges(); return(true); } } catch { } return(false); }
public bool SaveChanges(EstabelecimentoVM estabelecimento) { try { using (var db = new nosso_showEntities(Conexao.GetString())) { var u = db.usuario_estabelecimento.Single(x => x.IDUsuario == estabelecimento.ID); var e = u.evento.SingleOrDefault(x => x.ID == this.ID); if (e == null) { e = new evento { Ativo = true, Publicado = false, IDUsuario = u.IDUsuario, CNPJ = u.CNPJ, TipoUsuario = u.TipoUsuario, Cadastro = DateTime.Now, }; } e.DataAte = this.DataAte; e.DataDe = this.DataDe; e.Descricao = this.Descricao; e.HoraAte = this.HoraAte; e.HoraDe = this.HoraDe; e.MinutoAte = this.MinutoAte; e.MinutoDe = this.MinutoDe; e.Titulo = this.Titulo; if (e.ID > 0) { db.ObjectStateManager.ChangeObjectState(e, System.Data.EntityState.Modified); } else { u.evento.Add(e); } db.SaveChanges(); return(true); } } catch { } return(false); }
public void ContarVisualizacao() { try { using (var db = new nosso_showEntities(Conexao.GetString())) { var u = db.usuario_estabelecimento.First(x => x.IDUsuario == this.ID); u.Visualizacoes += 1; db.ObjectStateManager.ChangeObjectState(u, System.Data.EntityState.Modified); db.SaveChanges(); } } catch { } }
public bool SaveChanges(UsuarioVM usuario) { try { using (var db = new nosso_showEntities(Conexao.GetString())) { var u = db.usuario.SingleOrDefault(x => x.ID == usuario.ID); var r = u.usuario_redes_sociais; bool ex = r != null; if (r == null) { r = new usuario_redes_sociais { IDUsuario = u.ID, TipoUsuario = u.Tipo }; } r.Deezer = !string.IsNullOrEmpty(this.Deezer) ? this.Deezer : string.Empty; r.Embed = !string.IsNullOrEmpty(this.Embed) ? this.Embed : string.Empty; r.Facebook = !string.IsNullOrEmpty(this.Facebook) ? this.Facebook : string.Empty; r.GooglePlus = !string.IsNullOrEmpty(this.GooglePlus) ? this.GooglePlus : string.Empty; r.Instagram = !string.IsNullOrEmpty(this.Instagram) ? this.Instagram : string.Empty; r.SoundCloud = !string.IsNullOrEmpty(this.SoundCloud) ? this.SoundCloud : string.Empty; r.Spotify = !string.IsNullOrEmpty(this.Spotify) ? this.Spotify : string.Empty; r.Twitter = !string.IsNullOrEmpty(this.Twitter) ? this.Twitter : string.Empty; r.YouTube = !string.IsNullOrEmpty(this.Youtube) ? this.Youtube : string.Empty; if (ex) { db.ObjectStateManager.ChangeObjectState(r, System.Data.EntityState.Modified); } else { db.usuario_redes_sociais.AddObject(r); } db.SaveChanges(); return(true); } } catch (Exception e) { return(false); } }
public bool SaveChanges(UsuarioVM usuario) { try { using (var db = new nosso_showEntities(Conexao.GetString())) { bool ex = true; var av = db.usuario_avalia_usuario.FirstOrDefault(x => x.IDAvaliado == this.IDAvaliado && x.IDUsuario == usuario.ID); if (av == null) { ex = false; av = new usuario_avalia_usuario { IDAvaliado = this.IDAvaliado, IDUsuario = usuario.ID, TipoUsuario = usuario.TipoUsuario, TipoAvaliado = this.TipoAvaliado }; } av.Comentario = this.Comentario; av.Data = DateTime.Now; av.IDElogio = this.IDElogio; av.Nota = this.Nota; if (ex) { db.ObjectStateManager.ChangeObjectState(av, System.Data.EntityState.Modified); } else { db.usuario_avalia_usuario.AddObject(av); } db.SaveChanges(); return(true); } } catch { } return(false); }
public bool SaveChanges(UsuarioVM usuario) { try { using (var db = new nosso_showEntities(Conexao.GetString())) { var e = db.endereco.SingleOrDefault(x => x.IDUsuario == usuario.ID); if (e == null) { e = new endereco(); e.IDUsuario = usuario.ID; e.TipoUsuario = usuario.TipoUsuario; } e.Bairro = this.Bairro; e.CEP = Regex.Replace(this.CEP, @"[^0-9]", string.Empty); e.Cidade = this.Cidade; e.Complemento = this.Complemento; e.IDMunicipio = this.IDMunicipio; e.Latitude = string.Empty; e.Logradouro = this.Logradouro; e.Longitude = string.Empty; e.Numero = this.Numero; e.UF = this.UF; if (db.endereco.Any(x => x.IDUsuario == usuario.ID)) { db.ObjectStateManager.ChangeObjectState(e, System.Data.EntityState.Modified); } else { db.endereco.AddObject(e); } db.SaveChanges(); return(true); } } catch (Exception e) { return(false); } }
public bool SaveChanges(UsuarioVM usuario) { try { using (var db = new nosso_showEntities(Conexao.GetString())) { var u = db.usuario.SingleOrDefault(x => x.ID == usuario.ID); var e = u.endereco.FirstOrDefault(); if (e == null) { e = new endereco(); } e.Bairro = this.Bairro; e.CEP = Regex.Replace(this.CEP, @"[^0-9]", string.Empty); e.Cidade = this.Cidade; e.Complemento = !string.IsNullOrEmpty(this.Complemento) ? this.Complemento : string.Empty; e.IDMunicipio = this.IDMunicipio; e.Latitude = string.Empty; e.Logradouro = this.Logradouro; e.Longitude = string.Empty; e.Numero = this.Numero; e.UF = this.UF; if (u.endereco.Count > 0) { db.ObjectStateManager.ChangeObjectState(e, System.Data.EntityState.Modified); } else { u.endereco.Add(e); } db.SaveChanges(); return(true); } } catch { return(false); } }
public bool ToggleSetMusico(int idMusico) { try { using (var db = new nosso_showEntities(Conexao.GetString())) { var musico = db.usuario_musico.Single(x => x.IDUsuario == idMusico); var evento = db.evento.Single(x => x.ID == this.ID); if (evento.evento_musico.Any(x => x.IDMusico == musico.IDUsuario)) { var e = evento.evento_musico.Single(x => x.IDMusico == musico.IDUsuario); evento.evento_musico.Remove(e); } else { var e = new evento_musico { evento = evento, usuario_musico = musico, Confirmado = false, Data = DateTime.Now, Recusado = false }; db.evento_musico.AddObject(e); new MensagemEmail().Convite(this, new MusicoVM(musico.usuario)); } db.SaveChanges(); return(true); } } catch { } return(false); }
public usuario_premium GerarPagamento() { try { using (var db = new nosso_showEntities(Conexao.GetString())) { var u = db.usuario.First(x => x.ID == this.Usuario.ID); var premium = new usuario_premium(); if (u.usuario_premium.Any(x => !x.Aprovado && string.IsNullOrEmpty(x.Transacao))) { premium = u.usuario_premium.First(x => !x.Aprovado && string.IsNullOrEmpty(x.Transacao)); premium.Data = DateTime.Now; db.ObjectStateManager.ChangeObjectState(premium, System.Data.EntityState.Modified); } else { premium.Aprovado = false; premium.Data = DateTime.Now; premium.REF = Criptografia.Criptografar(this.Usuario.ID.ToString() + premium.Data.ToString("ddMMyyyyhhmmss") + this.Usuario.Tipo.ToString()); premium.IDUsuario = u.ID; premium.Pagamento = DateTime.MinValue; premium.TipoUsuario = u.Tipo; premium.Transacao = string.Empty; premium.Valor = this.Valor; premium.Vencimento = DateTime.MinValue; db.usuario_premium.AddObject(premium); } db.SaveChanges(); return(premium); } } catch (Exception e) { } return(null); }
public static Pagamento AtualizarPagamento(XmlDocument xml) { try { string referencia = xml.GetElementsByTagName("reference")[0].InnerText.ToString().Replace("-", string.Empty); string code = xml.GetElementsByTagName("code")[0].InnerText.ToString().Replace("-", string.Empty); string status = xml.GetElementsByTagName("status")[0].InnerText.ToString(); DateTime lastEventDate = DateTime.Parse(xml.GetElementsByTagName("lastEventDate")[0].InnerText.ToString()); using (var db = new nosso_showEntities(Conexao.GetString())) { var premium = db.usuario_premium.FirstOrDefault(x => x.REF.Equals(referencia)); if (premium != null) { if (!premium.Aprovado) { premium.Aprovado = status == "3"; premium.Pagamento = lastEventDate; if (string.IsNullOrEmpty(premium.Transacao)) { premium.Transacao = code; } premium.Vencimento = premium.Pagamento.AddDays(30); db.ObjectStateManager.ChangeObjectState(premium, System.Data.EntityState.Modified); db.SaveChanges(); } return(new Pagamento(premium)); } } } catch (Exception e) { } return(null); }
public ActionResult Sair() { try { string id = string.Empty; try { id = Criptografia.Descriptografar(base.Session["IDUsuario"].ToString()); } catch { } if (!string.IsNullOrEmpty(id)) { base.Session.RemoveAll(); base.Session.Clear(); base.Session.Abandon(); base.Session["IDUsuario"] = string.Empty; using (var db = new nosso_showEntities(Conexao.GetString())) { int idUsuario = int.Parse(Criptografia.Descriptografar(id)); var auths = db.autenticacao.Where(x => x.IDUsuario == idUsuario && x.Sessao == Session.SessionID).ToList(); for (int i = 0; i < auths.Count; i++) { db.autenticacao.DeleteObject(auths[i]); } db.SaveChanges(); } } } catch { } return(Redirect("/inicio/")); }
public ActionResult ConfirmarConta(string id) { try { using (var db = new nosso_showEntities(Conexao.GetString())) { var req = db.requisicao.SingleOrDefault(x => x.Hash == id && x.Ativa); if (req != null) { var u = req.usuario; u.Confirmado = true; req.Ativa = false; db.ObjectStateManager.ChangeObjectState(req, System.Data.EntityState.Modified); db.ObjectStateManager.ChangeObjectState(u, System.Data.EntityState.Modified); db.SaveChanges(); ViewBag.Nome = u.Nome; ViewBag.Mensagem = "Sua conta foi confirmada, efetue o acesso para continuar com o cadastro."; ViewBag.Button = "CONTINUAR"; } else { ViewBag.Nome = "Visitante"; ViewBag.Mensagem = "Este link não é mais válido, para continuar você deve entrar com seu acesso."; ViewBag.Button = "ENTRAR"; } return(View()); } } catch { return(Redirect("/entrar/")); } }
private bool SaveChanges() { try { using (var db = new nosso_showEntities(Conexao.GetString())) { var u = db.usuario.First(x => x.ID == this.IDUsuario); var t = db.imagem_tipo.First(x => x.ID == this.Tipo); var img = new imagem { ID = this.Data.ToString("ssmmhhyyyyMMdd"), Data = this.Data, Diretorio = this.Diretorio, TipoImagem = t.ID, }; if (img.TipoImagem != 4) { u.imagem.Add(img); } else { var e = db.evento.Single(x => x.ID == this.IDEvento && x.IDUsuario == this.IDUsuario); e.imagem.Add(img); } db.SaveChanges(); return(true); } } catch (Exception e) { } return(false); }