Beispiel #1
0
        public virtual ActionResult CadastrarVans(int id = 0)
        {
            var lista = _restClient.GetVansAll("");
            var model = new Vans();

            if (id > 0)
            {
                model = DAL.GetObjetoById <Vans>(id);
            }
            return(View(model));
        }
        public IEnumerable <VansListar> GetVansAll(long idconta, string termo)
        {
            var    u      = new Vans();
            var    f      = new Filtros(u);
            string filtro = "";

            if (!string.IsNullOrEmpty(termo))
            {
                f.AddLike(() => u.identificacao_van, termo, "");
                filtro = " and " + f;
            }
            return(DAL.ListarObjetos <VansListar>(string.Format("id_conta={0} {1}", idconta, filtro), "ds_van"));
        }
Beispiel #3
0
        public Respostas AddVans(Vans van)
        {
            var request = new RestRequest("api/vans/van", Method.POST);

            request.AddJsonBody(van);
            var a = _client.Execute <Respostas>(request);

            if (a.StatusCode != HttpStatusCode.OK)
            {
                a.Data = new Respostas();
            }
            return(a.Data);
        }
        public Respostas VAN([FromBody] Vans model)
        {
            Respostas response;

            try
            {
                var idBase = DAL.Gravar(model);
                response = new Respostas(true, "VAN incluída!", idBase);
            }
            catch (Exception ex)
            {
                response = new Respostas(true, ex.Message, 0);
            }
            return(response);
        }
Beispiel #5
0
        public ActionResult CadastrarVans(Vans van)
        {
            ViewBag.Notification = "";
            if (!ModelState.IsValid)
            {
                return(View(van));
            }

            /* if (viewModel.Id == 0)
             * {
             *
             *   Vans u = new Vans();
             *   Filtros f = new Filtros(u);
             *   f.Add(() => u.Email, viewModel.Email, FiltroExpressao.Igual);
             *   u = DAL.GetObjeto<Vans>(f);
             *   if (u != null)
             *   {
             *       this.AddNotification("Informação! Usuário já cadastrado.", NotificationType.Alerta);
             *       return View("~/views/usuario/incluir.cshtml", viewModel);
             *   }
             * }*/

            try
            {
                var resp = _restClient.AddVans(van);
            }
            catch (Exception ex)
            {
                AddErrors(ex);
                return(View(van));
            }
            if (van.id_van > 0)
            {
                this.AddNotification("VAN alterada.", NotificationType.Sucesso);
            }
            else
            {
                this.AddNotification("VAN incluída.", NotificationType.Sucesso);
            }


            var model = new Vans();

            return(View(model));
        }