public bool ValidarNomeUsuario(UsuarioVM usuario) { try { using (var db = new nosso_showEntities(Conexao.GetString())) { return(!db.usuario.Any(x => x.Username.ToLower() == this.Username.ToLower() && x.ID != usuario.ID)); } } catch { return(true); } }
public bool ValidarEmail(UsuarioVM usuario) { try { using (var db = new nosso_showEntities(Conexao.GetString())) { return(!db.usuario.Any(x => x.Email == this.Email && x.ID != usuario.ID)); } } catch { return(true); } }
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 AvaliacaoVM(UsuarioVM usuario, usuario avaliado) { this.Avaliacao = this.GetAvaliacao(usuario.ID, avaliado.ID); if (Avaliacao != null) { this.Comentario = this.Avaliacao.Comentario; this.IDAvaliado = this.Avaliacao.IDAvaliado; this.IDElogio = this.Avaliacao.IDElogio; this.Nota = this.Avaliacao.Nota; this.TipoAvaliado = this.Avaliacao.TipoAvaliado; } else { this.Comentario = string.Empty; this.IDAvaliado = avaliado.ID; this.IDElogio = 11; this.Nota = 1; this.TipoAvaliado = avaliado.Tipo; } }
private string GetSeguindoEventosJSON(List <evento> eventos) { var resultados = new List <Resultado>(); try { using (var db = new nosso_showEntities(Conexao.GetString())) { for (int i = 0; i < eventos.Count; i++) { var evento = eventos[i]; Resultado r = new Resultado { ID = evento.ID, Nome = evento.Titulo, Username = evento.usuario_estabelecimento.usuario.Username, Tipo = "Evento" }; try { r.Imagem = evento.imagem.Last(x => x.TipoImagem == 4).Diretorio; } catch { r.Imagem = "/Imagens/Views/user.svg"; } var usuario = new UsuarioVM(evento.usuario_estabelecimento.usuario); r.Endereco = usuario.GetEnderecoString(); resultados.Add(r); } } } catch { } return(JsonConvert.SerializeObject(resultados)); }
private string GetSeguindoEstabelecimentosJSON(List <usuario_estabelecimento> estabelecimentos) { var resultados = new List <Resultado>(); for (int i = 0; i < estabelecimentos.Count; i++) { var e = estabelecimentos[i]; Resultado r = new Resultado { ID = e.IDUsuario, Nome = e.usuario.Nome, Username = e.usuario.Username, Tipo = "Estabelecimento" }; try { r.Imagem = e.usuario.imagem.Last(x => x.TipoImagem == 1).Diretorio; } catch { r.Imagem = "/Imagens/Views/user.svg"; } var usuario = new UsuarioVM(e.usuario); r.Endereco = usuario.GetEnderecoString(); r.Badges = new List <string>(); r.Badges.Add(e.ambientacao.Descricao); resultados.Add(r); } return(JsonConvert.SerializeObject(resultados)); }