Ejemplo n.º 1
0
        public JsonResult BuscarDoacoes()
        {
            var search = new StringValues();
            var draw   = new StringValues();

            var requestName = HttpContext.Request.Query.TryGetValue("search[value]", out search);
            var requestDraw = HttpContext.Request.Query.TryGetValue("draw", out draw);

            var result = _app.GetAll(textSearch: search.SingleOrDefault());

            var arrayList = new ArrayList();

            foreach (var item in result.Itens)
            {
                var tiposangue = new ETipoSangue();
                tiposangue = (ETipoSangue)System.Enum.Parse(typeof(ETipoSangue), item.TipoSangue.ToString());

                var sangue = tiposangue.GetDescription();

                var alteracoes = $"<a class='btn-tiny btn-floating waves-effect waves-light blue edit-item' id='item-edit' href='#' data-id='{item.Id}'><i class='tiny material-icons'>edit</i></a>" +
                                 $"<a class='btn-tiny btn-floating waves-effect waves-light red delete-item' href='#' data-id='{item.Id}'><i class='tiny material-icons'>delete</i></a>";

                var obj = new object[] { item.Id, sangue, item.Doador.Nome, item.Cliente.Nome, item.DataDoacao.ToString("dd/MM/yyyy hh:MM"), item.Quantidade, alteracoes };
                arrayList.Add(obj);
            }

            var data = new { draw = draw.SingleOrDefault(), recordsTotal = result.TotalResults, recordsFiltered = result.Itens.Count(), data = arrayList };

            return(Json(data));
        }
        public PropertySelectResolver(StringValues properties)
        {
            var extracted = properties.SingleOrDefault()?.Split(',');

            if (extracted != null && extracted.Any())
            {
                _desiredProperties.AddRange(extracted);
            }
        }
Ejemplo n.º 3
0
        public JsonResult BuscarClientes()
        {
            var search = new StringValues();
            var draw   = new StringValues();

            var requestName = HttpContext.Request.Query.TryGetValue("search[value]", out search);
            var requestDraw = HttpContext.Request.Query.TryGetValue("draw", out draw);

            var result = _app.GetAll(textSearch: search.SingleOrDefault());

            var arrayList = new ArrayList();

            foreach (var item in result.Itens)
            {
                var obj = new object[] { item.Nome, item.Logradouro, item.Numero, item.Cidade, item.Bairro, item.CEP, item.Telefone };
                arrayList.Add(obj);
            }

            var data = new { draw = draw.SingleOrDefault(), recordsTotal = result.TotalResults, recordsFiltered = result.Itens.Count(), data = arrayList };

            return(Json(data));
        }