コード例 #1
0
ファイル: EntregasVM.cs プロジェクト: emersonsmp/MMarket
        private void PovoarListaItens()
        {
            string             cnpj = App.Current.Properties["Cnpj_user"].ToString();
            PedidoEntregaModel Resp = new PedidoEntregaModel();

            try
            {
                Resp = Service.Service.GetPedidosParaEntrega(cnpj, "2");

                if (Resp == null)
                {
                    IsVisible = true;
                    Aviso     = "Sem pedidos em processo de entregas";
                }
                else
                {
                    List <Pedido> Lista = new List <Pedido>((IEnumerable <Pedido>)Resp.pedidos);

                    for (int i = 0; i < Lista.Count; i++)
                    {
                        ListaDeEntregas.Add(Lista[i]);
                    }
                }
            }
            catch
            {
                App.Current.MainPage.DisplayAlert("Atenção", "Erro", "ok");
            }
        }
コード例 #2
0
        /// <summary>
        /// Chama a tela para editar um entrega
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Editar(Guid id)
        {
            //Se não tiver login, encaminhar para a tela de login
            if (string.IsNullOrWhiteSpace(SessaoUsuario.SessaoLogin.Identificacao))
            {
                return(RedirectToAction("Login", "Usuario"));
            }

            if (!SessaoUsuario.SessaoLogin.Administrador)
            {
                ViewBag.MensagemErro = "Para alterar os dados de uma entrega é necessário " +
                                       $"logar com um usuário administrador.";
                return(View("SemPermissao"));
            }

            //Model a ser populada
            PedidoEntregaModel model           = new PedidoEntregaModel();
            string             mensagemRetorno = "";

            //Obtem o entrega pelo ID
            if (!this.ObterPedidoEntrega(id, ref model, ref mensagemRetorno))
            {
                ViewBag.MensagemErro = mensagemRetorno;
                return(View("Erro"));
            }

            TempData["Retorno"] = "EDITANDO";

            //Chamar a view
            return(View(model));
        }
コード例 #3
0
        /// <summary>
        /// Obtem um entrega e converte em Model
        /// </summary>
        /// <param name="id"></param>
        /// <param name="model"></param>
        /// <param name="mensagemErro"></param>
        /// <returns></returns>
        private bool ObterPedidoEntrega(Guid id, ref PedidoEntregaModel model, ref string mensagemErro)
        {
            //Preparar a requisição e o retorno
            RetornoObterDto <PedidoEntregaDto> retorno = new RetornoObterDto <PedidoEntregaDto>();
            RequisicaoObterDto requisicaoDto           = new RequisicaoObterDto()
            {
                Id            = id,
                Identificacao = SessaoUsuario.SessaoLogin.Identificacao,
                IdUsuario     = SessaoUsuario.SessaoLogin.IdUsuario
            };

            //Consumir o serviço
            PedidoEntregaBll entregaBll = new PedidoEntregaBll(true);

            entregaBll.Obter(requisicaoDto, ref retorno);

            //Tratar o retorno
            if (retorno.Retorno == false)
            {
                mensagemErro = retorno.Mensagem;
                return(false);
            }
            else
            {
                //Converter para Model
                return(model.ConverterDtoParaModel(retorno.Entidade, ref mensagemErro));
            }
        }
コード例 #4
0
        public ActionResult Editar(PedidoEntregaModel model)
        {
            //Se não tiver login, encaminhar para a tela de login
            if (string.IsNullOrWhiteSpace(SessaoUsuario.SessaoLogin.Identificacao))
            {
                return(RedirectToAction("Login", "Usuario"));
            }

            if (!SessaoUsuario.SessaoLogin.Administrador)
            {
                ViewBag.MensagemErro = "Para alterar os dados de uma entrega é necessário " +
                                       $"logar com um usuário administrador.";
                return(View("SemPermissao"));
            }

            //Valida a entidade recebida
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            //Converte para DTO
            PedidoEntregaDto entregaDto   = new PedidoEntregaDto();
            string           mensagemErro = "";

            if (!model.ConverterModelParaDto(ref entregaDto, ref mensagemErro))
            {
                ViewBag.MensagemErro = mensagemErro;
                return(View("Erro"));
            }

            //Preparar requisição e retorno
            RetornoDto retorno = new RetornoDto();
            RequisicaoEntidadeDto <PedidoEntregaDto> requisicaoDto = new RequisicaoEntidadeDto <PedidoEntregaDto>()
            {
                EntidadeDto   = entregaDto,
                Identificacao = SessaoUsuario.SessaoLogin.Identificacao,
                IdUsuario     = SessaoUsuario.SessaoLogin.IdUsuario
            };

            //Consumir o serviço
            PedidoEntregaBll entregaBll = new PedidoEntregaBll(true);

            entregaBll.Editar(requisicaoDto, ref retorno);

            //Tratar o retorno
            if (retorno.Retorno == false)
            {
                ModelState.AddModelError("", retorno.Mensagem);
                return(View(model));
            }

            TempData["Retorno"] = "ALTERADO";

            //Voltar para o visualizar do entrega
            return(RedirectToAction("Index"));
        }
コード例 #5
0
        public ListaDePedidosVM(PedidoEntregaModel Pedidos)
        {
            IsVisible      = false;
            ListaDePedidos = new List <Pedido>();
            PovoarLista(Pedidos);

            GoVerPedidoCommand = new Command <object>(GoVerPedido);
            Analytics.TrackEvent("Evento Vizualizar pedidos");
            //Crashes.GenerateTestCrash();
        }
コード例 #6
0
        private void UpdatePedidos(PedidoEntregaModel pedidos)
        {
            List <Pedido> ListaPedidos = new List <Pedido>((IEnumerable <Pedido>)pedidos.pedidos);
            var           productTapGestureRecognizer = new TapGestureRecognizer();

            productTapGestureRecognizer.Tapped += GoPedido;


            for (int i = 0; i < ListaPedidos.Count; i++)
            {
                var item = new TemplatePedido();
                item.BindingContext = ListaPedidos[i];
                item.GestureRecognizers.Add(productTapGestureRecognizer);
                PedidosStackLayout.Children.Add(item);
            }
        }
コード例 #7
0
        private void PovoarLista(PedidoEntregaModel Pedidos)
        {
            if (Pedidos.quant != 0)
            {
                List <Pedido> Lista = new List <Pedido>((IEnumerable <Pedido>)Pedidos.pedidos);

                for (int i = 0; i < Lista.Count; i++)
                {
                    ListaDePedidos.Add(Lista[i]);
                }
            }
            else
            {
                Aviso     = "Não há pedidos Para serem exibidos aqui";
                IsVisible = true;
            }
        }
コード例 #8
0
ファイル: Service.cs プロジェクト: emersonsmp/MMarket
        public static PedidoEntregaModel GetPedidosParaEntrega(string cnpj, string FlagEntrega)
        {
            string urlPedidos      = "https://ganhemais.site/api/Pedidos.php?flag={0}&cnpj={1}";
            string NovoEnderecoURL = string.Format(urlPedidos, FlagEntrega, cnpj);

            WebClient          wc       = new WebClient();
            string             Conteudo = wc.DownloadString(NovoEnderecoURL);
            PedidoEntregaModel pedidos  = new PedidoEntregaModel();

            try
            {
                pedidos = JsonConvert.DeserializeObject <PedidoEntregaModel>(Conteudo);
            }
            catch
            {
                //PEDIDO NULL - TODA REQUISIÇÃO DEVE RETORNAR ALGO DEVE SER TRATADO NO PHP
                pedidos = null;
                return(pedidos);
            }

            return(pedidos);
        }
コード例 #9
0
ファイル: HomeMercadoVM.cs プロジェクト: emersonsmp/MMarket
        void GetPedidos()
        {
            string cnpj = App.Current.Properties["Cnpj_user"].ToString();

            try
            {
                //Pedidos = Service.Service.GetPedidos(cnpj);
                Pedidos = Service.Service.GetPedidosParaEntrega(cnpj, "1");

                if (Pedidos == null)
                {
                    QuantidadeDePedidos = "0";
                }
                else
                {
                    QuantidadeDePedidos = Pedidos.quant.ToString();
                }
            }
            catch
            {
                QuantidadeDePedidos = "0";
            }
        }
コード例 #10
0
        /// <summary>
        /// Chama a tela para visualizar um fornecedor
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Visualizar(Guid id)
        {
            //Se não tiver login, encaminhar para a tela de login
            if (string.IsNullOrWhiteSpace(SessaoUsuario.SessaoLogin.Identificacao))
            {
                return(RedirectToAction("Login", "Usuario"));
            }

            //Model a ser populada
            PedidoEntregaModel model           = new PedidoEntregaModel();
            string             mensagemRetorno = "";

            //Obtem o fornecedor pelo ID
            if (!this.ObterPedidoEntrega(id, ref model, ref mensagemRetorno))
            {
                ViewBag.MensagemErro = mensagemRetorno;
                return(View("Erro"));
            }

            TempData["Retorno"] = "VISUALIZANDO";

            //Chamar a view
            return(View(model));
        }
コード例 #11
0
 public ListaDePedidosView(PedidoEntregaModel Pedidos)
 {
     InitializeComponent();
     BindingContext = new ListaDePedidosVM(Pedidos);
 }
コード例 #12
0
 //public Command GoPedidoCommand { get; set; }
 public PedidosView(PedidoEntregaModel pedido)
 {
     InitializeComponent();
     UpdatePedidos(pedido);
 }