Пример #1
0
        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 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 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);
        }
Пример #4
0
        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);
        }
Пример #5
0
        /*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 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 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);
        }
Пример #8
0
        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);
        }
Пример #9
0
        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);
        }
Пример #10
0
        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);
        }
Пример #11
0
        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);
        }
Пример #12
0
        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);
        }
Пример #13
0
        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);
        }
Пример #14
0
        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);
        }