Beispiel #1
0
        public JsonResult SalvarLocaisArmazenamento(LocaisArmazenamentoModel model)
        {
            var resultado = "OK";
            var mensagens = new List <string>();
            var idSalvo   = string.Empty;

            if (!ModelState.IsValid)
            {
                resultado = "AVISO";
                mensagens = ModelState.Values.SelectMany(x => x.Errors).Select(x => x.ErrorMessage).ToList();
            }
            else
            {
                try
                {
                    var id = model.Salvar();
                    if (id > 0)
                    {
                        idSalvo = id.ToString();
                    }
                    else
                    {
                        resultado = "ERRO";
                    }
                }
                catch (Exception ex)
                {
                    resultado = "ERRO";
                }
            }
            return(Json(new { Resultado = resultado, Mensagens = mensagens, IdSalvo = idSalvo }));
        }
Beispiel #2
0
        public ActionResult Index()
        {
            ViewBag.ListaTamPag             = new SelectList(new int[] { _quantMaxLinhasPorPagina, 10, 15, 20 }, _quantMaxLinhasPorPagina);
            ViewBag.QuantMaxLinhasPorPagina = _quantMaxLinhasPorPagina;
            ViewBag.PaginaAtual             = 1;

            var lista = LocaisArmazenamentoModel.RecuperarLista(ViewBag.PaginaAtual, _quantMaxLinhasPorPagina);
            var quant = LocaisArmazenamentoModel.RecuperarQuantidade();

            var difQuantPaginas = (quant % ViewBag.QuantMaxLinhasPorPagina) > 0 ? 1 : 0;

            ViewBag.QuantPaginas = (quant / ViewBag.QuantMaxLinhasPorPagina) + difQuantPaginas;

            return(View(lista));
        }
Beispiel #3
0
 public JsonResult ExcluirLocaisArmazenamento(int id)
 {
     return(Json(LocaisArmazenamentoModel.ExcluirPeloId(id)));
 }
Beispiel #4
0
 public JsonResult RecuperarLocaisArmazenamento(int id)
 {
     return(Json(LocaisArmazenamentoModel.RecuperarPeloId(id)));
 }
Beispiel #5
0
        public JsonResult LocaisArmazenamentoPagina(int pagina, int tamPag)
        {
            var lista = LocaisArmazenamentoModel.RecuperarLista(pagina, tamPag);

            return(Json(lista));
        }