public DtoChave cadastrarUsuario(DtoUsuario usuario) { Chave mChave = new Chave(); DBCatalogDataContext dataContext = new DBCatalogDataContext(); var usuarioBanco = dataContext.tb_Usuarios.FirstOrDefault(u => u.email == usuario.email); if(usuarioBanco == null) //nenhum email encontrado (cadastrar usuario) { usuarioBanco = new Linq.tb_Usuario(); usuarioBanco.email = usuario.email; usuarioBanco.senha = usuario.senha; usuarioBanco.nome = usuario.nome; dataContext.tb_Usuarios.InsertOnSubmit(usuarioBanco); dataContext.SubmitChanges(); //criando chave var usuarioRecemCadastrado = dataContext.tb_Usuarios.FirstOrDefault(u => u.email == usuario.email); DtoChave chave = mChave.criarChave(usuarioRecemCadastrado.id); return chave; } else { throw new DtoExcecao(DTO.Enum.CampoInvalido, "Email ja existente"); } }
public string abrirEstabelecimento(string dtoChave, string dtoEnderecoEstabelecimento) { JavaScriptSerializer js = new JavaScriptSerializer(); DtoRetorno retorno; DtoChave chave = js.Deserialize<DtoChave>(dtoChave); DtoEnderecoEstabelecimento enderecoEstabelecimento = js.Deserialize<DtoEnderecoEstabelecimento>(dtoEnderecoEstabelecimento); DtoEnderecoEstabelecimento estabelecimento; Chave mChave = new Chave(); try { mChave.validarChave(chave); Estabelecimento mEstabelecimento = new Estabelecimento(); estabelecimento = mEstabelecimento.abrirEstabelecimento(enderecoEstabelecimento.id); //estabelecimento.itens = mEstabelecimento.procurarProduto(estabelecimento, new DtoProduto()); chave = mChave.atualizarChave(chave); retorno = new DtoRetornoObjeto(chave, estabelecimento); } catch (DtoExcecao ex) { retorno = ex.ToDto(); } catch (Exception ex) { retorno = new DtoRetornoErro(ex.Message); } /*Objeto: DtoEnderecoEstabelecimento com DtoEstabelecimento e Array de DtoItem com DtoProduto*/ return js.Serialize(retorno); }
public string buscarItem(string dtoChave, string dtoProduto, string dtoEstabelecimento) { JavaScriptSerializer js = new JavaScriptSerializer(); DtoRetorno retorno = new DtoRetorno("ACK"); DtoChave chave = js.Deserialize<DtoChave>(dtoChave); DtoProduto produto = js.Deserialize<DtoProduto>(dtoProduto); DtoEnderecoEstabelecimento enderecoEstabelecimento = js.Deserialize<DtoEnderecoEstabelecimento>(dtoEstabelecimento); Chave mChave = new Chave(); try { mChave.validarChave(chave); Item mItem = new Item(); DtoItem item = mItem.abrirItem(produto.id, enderecoEstabelecimento.id); chave = mChave.atualizarChave(chave); retorno = new DtoRetornoObjeto(chave, item); } catch (DtoExcecao ex) { retorno = ex.ToDto(); } catch (Exception ex) { retorno = new DtoRetornoErro(ex.Message); } /*Objeto: DtoItem com DtoProduto com DtoTipoProduto e DtoFabricante*/ return js.Serialize(retorno); }
public string criarEstabelecimento(string dtoChave, string dtoEnderecoEstabelecimento) { JavaScriptSerializer js = new JavaScriptSerializer(); DtoRetorno retorno; DtoChave chave = js.Deserialize<DtoChave>(dtoChave); DtoEnderecoEstabelecimento enderecoEstabelecimento = js.Deserialize<DtoEnderecoEstabelecimento>(dtoEnderecoEstabelecimento); DtoEnderecoEstabelecimento estabelecimento; Chave mChave = new Chave(); try { mChave.validarChave(chave); Estabelecimento mEstabelecimento = new Estabelecimento(); estabelecimento = mEstabelecimento.cadastrarEstabelecimento(enderecoEstabelecimento); chave = mChave.atualizarChave(chave); retorno = new DtoRetornoObjeto(chave, estabelecimento); } catch (DtoExcecao ex) { retorno = ex.ToDto(); } catch (Exception ex) { retorno = new DtoRetornoErro(ex.Message); } /*Objeto: DtoEnderecoEstabelecimento com DtoEstabelecimento*/ return js.Serialize(retorno); }
public string criarLista(string dtoChave, string dtoLista) { JavaScriptSerializer js = new JavaScriptSerializer(); DtoRetorno retorno; DtoChave chave = js.Deserialize<DtoChave>(dtoChave); DtoLista lista = js.Deserialize<DtoLista>(dtoLista); Chave mChave = new Chave(); try { mChave.validarChave(chave); Lista mLista = new Lista(); lista.idUsuario = chave.idUsuario; lista = mLista.criarLista(lista); chave = mChave.atualizarChave(chave); retorno = new DtoRetornoObjeto(chave, lista); } catch (DtoExcecao ex) { retorno = ex.ToDto(); } catch (Exception ex) { retorno = new DtoRetornoErro(ex.Message); } /*Objeto: DtoLista puro*/ return js.Serialize(retorno); }
/*Não Implementado*/ public string adicionarProduto(string dtoChave, string dtoLista, string dtoProdutoDaLista) { JavaScriptSerializer js = new JavaScriptSerializer(); DtoRetorno retorno; DtoChave chave = js.Deserialize<DtoChave>(dtoChave); DtoLista lista = js.Deserialize<DtoLista>(dtoLista); Chave mChave = new Chave(); try { mChave.validarChave(chave); DtoProdutoDaLista produtoDaLista = js.Deserialize<DtoProdutoDaLista>(dtoProdutoDaLista); Lista mLista = new Lista(); produtoDaLista = mLista.adicionarProduto(produtoDaLista); chave = mChave.atualizarChave(chave); retorno = new DtoRetornoObjeto(chave, produtoDaLista); } catch (DtoExcecao ex) { retorno = ex.ToDto(); } catch (Exception ex) { retorno = new DtoRetornoErro(ex.Message); } /*Objeto: DtoProdutoDaLista com o DtoProduto*/ return js.Serialize(retorno); }
public DtoChave logar(string email, string senha) { Chave mChave = new Chave(); DBCatalogDataContext dataContext = new DBCatalogDataContext(); var usuarioBanco = dataContext.tb_Usuarios.FirstOrDefault(u => u.email == email && u.senha == senha); var usuarioSenhaAlternativaBanco = dataContext.tb_SenhaAlternativas.FirstOrDefault(u => u.tb_Usuario.email == email && u.senha == senha); var verificarSenhaAlternativaBanco = dataContext.tb_SenhaAlternativas.FirstOrDefault(u => u.tb_Usuario.email == email); if (usuarioBanco != null) { if (verificarSenhaAlternativaBanco != null) { dataContext.tb_SenhaAlternativas.DeleteOnSubmit(verificarSenhaAlternativaBanco); dataContext.SubmitChanges(); } DtoChave chave = mChave.criarChave(usuarioBanco.id); return chave; } else if (usuarioSenhaAlternativaBanco != null) { DtoChave chave = new DtoChave(); chave.idUsuario = usuarioSenhaAlternativaBanco.idUsuario; chave.token = "00000"; chave.ultimoAcesso = new TimeSpan().ToString(); return chave; } else { throw new DtoExcecao(DTO.Enum.CampoInvalido, "Email e Senha não conferem"); } }
public string abrirProduto(string dtoChave, string dtoProduto) { JavaScriptSerializer js = new JavaScriptSerializer(); DtoRetorno retorno = new DtoRetorno("ACK"); DtoChave chave = js.Deserialize<DtoChave>(dtoChave); Chave mChave = new Chave(); try { mChave.validarChave(chave); DtoProduto produto = js.Deserialize<DtoProduto>(dtoProduto); Produto mProduto = new Produto(); produto = mProduto.abrirProduto(produto.id); chave = mChave.atualizarChave(chave); retorno = new DtoRetornoObjeto(chave, produto); } catch (DtoExcecao ex) { retorno = ex.ToDto(); } catch (Exception ex) { retorno = new DtoRetornoErro(ex.Message); } /*Objeto: DtoProduto com DtoTipoProduto e DtoFabricante*/ return js.Serialize(retorno); }
public DtoChave alterarDadosCadastrais(string senha, string novaSenha) { Chave mChave = new Chave(); DBCatalogDataContext dataContext = new DBCatalogDataContext(); var usuarios = dataContext.tb_Usuarios.FirstOrDefault(u => u.senha == senha); if (usuarios != null) { DtoChave chave = mChave.criarChave(usuarios.id); usuarios.senha = novaSenha; dataContext.SubmitChanges(); return chave; } else { throw new DtoExcecao(DTO.Enum.CampoInvalido, "Senha incorreto!"); } }
public string criarProduto(string dtoChave, string dtoProduto) { JavaScriptSerializer js = new JavaScriptSerializer(); DtoRetorno retorno; DtoProduto produto = js.Deserialize<DtoProduto>(dtoProduto); if (produto.nome.Length < 3 || produto.idTipo < 1) { retorno = (new DtoExcecao(DTO.Enum.CriteriosDeCadastroInsuficientes, "Nome do produto e Tipo do Produto")).ToDto(); return js.Serialize(retorno); } DtoChave chave = js.Deserialize<DtoChave>(dtoChave); Chave mChave = new Chave(); try { mChave.validarChave(chave); Produto mProduto = new Produto(); produto = mProduto.cadastrarProduto(produto); chave = mChave.atualizarChave(chave); retorno = new DtoRetornoObjeto(chave, produto); } catch (DtoExcecao ex) { retorno = ex.ToDto(); } catch (Exception ex) { retorno = new DtoRetornoErro(ex.Message); } /*Objeto: DtoProduto com DtoTipoProduto e DtoFabricante*/ return js.Serialize(retorno); }
public string listarItensEm(string dtoChave, string dtoLista, string dtoEnderecoEstabelecimento) { JavaScriptSerializer js = new JavaScriptSerializer(); DtoRetorno retorno; DtoChave chave = js.Deserialize<DtoChave>(dtoChave); DtoLista lista = js.Deserialize<DtoLista>(dtoLista); DtoEnderecoEstabelecimento estabelecimento = js.Deserialize<DtoEnderecoEstabelecimento>(dtoEnderecoEstabelecimento); Chave mChave = new Chave(); try { mChave.validarChave(chave); Lista mLista = new Lista(); lista = mLista.listarItensEm(lista.id, estabelecimento.id); chave = mChave.atualizarChave(chave); retorno = new DtoRetornoObjeto(chave, lista); } catch (DtoExcecao ex) { retorno = ex.ToDto(); } catch (Exception ex) { retorno = new DtoRetornoErro(ex.Message); } /*Objeto: DtoLista com array de DtoProdutoDaLista contendo DtoProduto e DtoItem (no mesmo indice, caso o item exista), contendo o endereço do estab e o estab*/ return js.Serialize(retorno); }
// Use this for initialization void Start() { c = chave.GetComponent <Chave>(); //Physics.IgnoreCollision(GetComponent<Collider>(), GetComponent<Collider>()); }
public bool Equals(ChaveValorDTO <T> other) { return(Chave.Equals(other.Chave) && Descricao.Equals(other.Descricao)); }
public TokenService(IOptions <Chave> chave, JwtSecurityTokenHandler geradorToken) { this.chave = chave.Value; this.geradorToken = geradorToken; }
public string removerProduto(string dtoChave, string dtoLista, string dtoProduto) { JavaScriptSerializer js = new JavaScriptSerializer(); DtoRetorno retorno; DtoChave chave = js.Deserialize<DtoChave>(dtoChave); DtoProdutoDaLista produtoDaLista = js.Deserialize<DtoProdutoDaLista>(dtoProduto); try { Chave mChave = new Chave(); mChave.validarChave(chave); Lista mLista = new Lista(); mLista.removerProduto(produtoDaLista.id); chave = mChave.atualizarChave(chave); retorno = new DtoRetornoObjeto(chave); } catch (DtoExcecao ex) { retorno = ex.ToDto(); } catch (Exception ex) { retorno = new DtoRetornoErro(ex.Message); } /*Objeto: apenas a chave*/ return js.Serialize(retorno); }
public string pesquisarLista(string dtoChave) { JavaScriptSerializer js = new JavaScriptSerializer(); DtoRetorno retorno; DtoChave chave = js.Deserialize<DtoChave>(dtoChave); DtoLista[] listas; Chave mChave = new Chave(); try { mChave.validarChave(chave); Lista mLista = new Lista(); listas = mLista.pesquisarListas(chave.idUsuario); chave = mChave.atualizarChave(chave); retorno = new DtoRetornoObjeto(chave, listas); } catch (DtoExcecao ex) { retorno = ex.ToDto(); } catch (Exception ex) { retorno = new DtoRetornoErro(ex.Message); } /*Objeto: Array de DtoLista*/ return js.Serialize(retorno); }
public void IniciarTestes() { js = new JavaScriptSerializer(); mChave = new Chave(); chave = mChave.criarChave(idUsuario); produto = new DtoProduto(); cProduto = new ControllerProduto(); mProduto = new Produto(); }
public string listarEstabelecimentosProssuidores(string dtoChave, string dtoProduto) { JavaScriptSerializer js = new JavaScriptSerializer(); DtoRetorno retorno = new DtoRetorno("ACK"); DtoChave chave = js.Deserialize<DtoChave>(dtoChave); DtoProduto produto = js.Deserialize<DtoProduto>(dtoProduto); Chave mChave = new Chave(); try { mChave.validarChave(chave); Produto mProduto = new Produto(); DtoItem[] itens = mProduto.estabelecimentosPossuidores(produto.id); chave = mChave.atualizarChave(chave); retorno = new DtoRetornoObjeto(chave, itens); } catch (DtoExcecao ex) { retorno = ex.ToDto(); } catch (Exception ex) { retorno = new DtoRetornoErro(ex.Message); } /*Objeto: DtoItem com DtoProduto com DtoTipoProduto e DtoFabricante*/ return js.Serialize(retorno); }
public string pesquisarProdutos(string dtoChave, string dtoEnderecoEstabelecimento, string parametros) { JavaScriptSerializer js = new JavaScriptSerializer(); DtoRetorno retorno; DtoChave chave = js.Deserialize<DtoChave>(dtoChave); DtoEnderecoEstabelecimento enderecoEstabelecimento = js.Deserialize<DtoEnderecoEstabelecimento>(dtoEnderecoEstabelecimento); DtoProduto parametrosProduto = js.Deserialize<DtoProduto>(parametros); DtoItem[] produtosDoEstabelecimento; Chave mChave = new Chave(); try { mChave.validarChave(chave); Estabelecimento mEstabelecimento = new Estabelecimento(); chave = mChave.atualizarChave(chave); produtosDoEstabelecimento = mEstabelecimento.procurarProduto(enderecoEstabelecimento, parametrosProduto); retorno = new DtoRetornoObjeto(chave, produtosDoEstabelecimento); } catch (DtoExcecao ex) { retorno = ex.ToDto(); } catch (Exception ex) { retorno = new DtoRetornoErro(ex.Message); } /*Objeto: Array de DtoItem com DtoProduto*/ return js.Serialize(retorno); }
public string pesquisarProduto(string dtoChave, string parametros) { JavaScriptSerializer js = new JavaScriptSerializer(); DtoRetorno retorno; DtoProduto param = js.Deserialize<DtoProduto>(parametros); if (param.nome.Length < 3 && param.tipoCodigoDeBarras.Length < 3 && (param.tipo == null || param.tipo.tipo.Length < 3) && (param.fabricante == null || param.fabricante.fabricante.Length < 3)) { retorno = (new DtoExcecao(DTO.Enum.CriteriosDeBuscaInsuficientes)).ToDto(); return js.Serialize(retorno); } DtoChave chave = js.Deserialize<DtoChave>(dtoChave); Chave mChave = new Chave(); try { mChave.validarChave(chave); Produto mProduto = new Produto(); DtoProduto[] produtos = mProduto.pesquisarProduto(param); chave = mChave.atualizarChave(chave); retorno = new DtoRetornoObjeto(chave, produtos); } catch (DtoExcecao ex) { retorno = ex.ToDto(); } catch (Exception ex) { retorno = new DtoRetornoErro(ex.Message); } /*Objeto: Array de DtoProdutos com DtoTipoProduto e DtoFabricante*/ return js.Serialize(retorno); }
public string finalizarCheckin(string dtoChave, string dtoEnderecoEstabelecimento, string dtoItensComprados) { JavaScriptSerializer js = new JavaScriptSerializer(); DtoRetorno retorno; DtoChave chave = js.Deserialize<DtoChave>(dtoChave); DtoEnderecoEstabelecimento enderecoEstabelecimento = js.Deserialize<DtoEnderecoEstabelecimento>(dtoEnderecoEstabelecimento); List<DtoProdutoDaLista> itensComprados = js.Deserialize<List<DtoProdutoDaLista>>(dtoItensComprados); Chave mChave = new Chave(); try { mChave.validarChave(chave); Estabelecimento mEstabelecimento = new Estabelecimento(); enderecoEstabelecimento = mEstabelecimento.abrirEstabelecimento(enderecoEstabelecimento.id); chave = mChave.atualizarChave(chave); retorno = new DtoRetornoObjeto(chave); Produto mProduto = new Produto(); Item mItem = new Item(); foreach (DtoProdutoDaLista produtoDaLista in itensComprados) { if (produtoDaLista.item.produto.id == 0) produtoDaLista.item.produto = mProduto.cadastrarProduto(produtoDaLista.item.produto); produtoDaLista.item = mItem.criarItem(produtoDaLista.item.produto.id, produtoDaLista.item.preco, enderecoEstabelecimento.id); } } catch (DtoExcecao ex) { retorno = ex.ToDto(); } catch (Exception ex) { retorno = new DtoRetornoErro(ex.Message); } /*Objeto: DtoRetorno com Ack*/ return js.Serialize(retorno); }
public List <Chave> List() { var chaveA = new Chave() { Nome = "Grupo A", Times = new List <Time>() { new Time() { Id = 1, Nome = "Russia", Bandeira = "RUS" }, new Time() { Id = 2, Nome = "Saudi Arabia", Bandeira = "KSA" }, new Time() { Id = 3, Nome = "Egypt", Bandeira = "EGY" }, new Time() { Id = 4, Nome = "Uruguay", Bandeira = "URU" }, } }; var chaveB = new Chave() { Nome = "Grupo B", Times = new List <Time>() { new Time() { Id = 5, Nome = "Portugal", Bandeira = "POR" }, new Time() { Id = 6, Nome = "Spain", Bandeira = "ESP" }, new Time() { Id = 7, Nome = "Morocco", Bandeira = "MAR" }, new Time() { Id = 8, Nome = "IR Iran", Bandeira = "IRN" }, } }; var chaveC = new Chave() { Nome = "Grupo C", Times = new List <Time>() { new Time() { Id = 9, Nome = "France", Bandeira = "FRA" }, new Time() { Id = 10, Nome = "Australia", Bandeira = "AUS" }, new Time() { Id = 11, Nome = "Peru", Bandeira = "PER" }, new Time() { Id = 12, Nome = "Denmark", Bandeira = "DEN" }, } }; var chaveD = new Chave() { Nome = "Grupo D", Times = new List <Time>() { new Time() { Id = 13, Nome = "Argentina", Bandeira = "ARG" }, new Time() { Id = 14, Nome = "Iceland", Bandeira = "ISL" }, new Time() { Id = 15, Nome = "Croatia", Bandeira = "CRO" }, new Time() { Id = 16, Nome = "Nigeria", Bandeira = "NGA" }, } }; var chaveE = new Chave() { Nome = "Grupo E", Times = new List <Time>() { new Time() { Id = 17, Nome = "Brazil", Bandeira = "BRA" }, new Time() { Id = 18, Nome = "Switzerland", Bandeira = "SUI" }, new Time() { Id = 19, Nome = "Costa Rica", Bandeira = "CRC" }, new Time() { Id = 20, Nome = "Serbia", Bandeira = "SRB" }, } }; var chaveF = new Chave() { Nome = "Grupo F", Times = new List <Time>() { new Time() { Id = 21, Nome = "Germany", Bandeira = "GER" }, new Time() { Id = 22, Nome = "Mexico", Bandeira = "MEX" }, new Time() { Id = 23, Nome = "Sweden", Bandeira = "SWE" }, new Time() { Id = 24, Nome = "Korea Republic", Bandeira = "KOR" }, } }; var chaveG = new Chave() { Nome = "Grupo G", Times = new List <Time>() { new Time() { Id = 25, Nome = "Belgium", Bandeira = "BEL" }, new Time() { Id = 26, Nome = "Panama", Bandeira = "PAN" }, new Time() { Id = 27, Nome = "Tunisia", Bandeira = "TUN" }, new Time() { Id = 28, Nome = "England", Bandeira = "ENG" }, } }; var chaveH = new Chave() { Nome = "Grupo H", Times = new List <Time>() { new Time() { Id = 29, Nome = "Poland", Bandeira = "POL" }, new Time() { Id = 30, Nome = "Senegal", Bandeira = "SEN" }, new Time() { Id = 31, Nome = "Colombia", Bandeira = "COL" }, new Time() { Id = 32, Nome = "Japan", Bandeira = "JPN" }, } }; var chaves = new List <Chave>(); chaves.Add(chaveA); chaves.Add(chaveB); chaves.Add(chaveC); chaves.Add(chaveD); chaves.Add(chaveE); chaves.Add(chaveF); chaves.Add(chaveG); chaves.Add(chaveH); return(chaves); }