Пример #1
0
        public IActionResult GetRowsFiltered(string nameTable, string listFilter)
        {
            var filterList = new List <object>();

            try
            {
                List <List <object>[]> table;
                IControlRowsTable      controlTable = new ControlTable();
                if (nameTable.Equals("tableDrugs") || nameTable.Equals("exjvnlpTable"))
                {
                    table = AllTableJvnlp;
                }
                else
                {
                    table = CalcDrugs;
                }

                filterList = controlTable.FilterRows(nameTable, listFilter, table);
            }
            catch (Exception e)
            {
                return(new JsonResult(new { message = e.Message })
                {
                    StatusCode = 500
                });
            }

            var jsonFilterList = JsonConvert.SerializeObject(filterList.Take(VisibleLines));

            return(new JsonResult(new
            {
                filterRowList = jsonFilterList,
                filterListLength = filterList.Take(VisibleLines).Count() - 3,
                filterListViewLength = filterList.Count - 3
            })
            {
                StatusCode = 200
            });
        }
Пример #2
0
        public IActionResult GetRowsNavigate(string nameTable, string nameButton, int idList, string listFilter)
        {
            try
            {
                List <List <object>[]> table;
                IControlRowsTable      controlTable = new ControlTable();
                if (nameTable.Equals("tableDrugs") || nameTable.Equals("exjvnlpTable"))
                {
                    table = AllTableJvnlp;
                }
                else
                {
                    table = CalcDrugs;
                }

                var filterList = controlTable.FilterRows(nameTable, listFilter, table);
                var nextCount  = idList * VisibleLines;
                switch (nameButton)
                {
                case "startlist":
                    idList    = 1;
                    nextCount = 0;
                    break;

                case "nextlist":
                    if (nextCount > filterList.Count)
                    {
                        return(new JsonResult(null));
                    }
                    idList++;
                    break;

                case "prevlist":
                    if (nextCount <= VisibleLines)
                    {
                        return(new JsonResult(null));
                    }

                    idList--;
                    nextCount = (idList - 1) * VisibleLines;
                    break;
                }

                var viewList = filterList.Skip(nextCount).Take(VisibleLines);

                var jsonFilterList = JsonConvert.SerializeObject(viewList);

                return(new JsonResult(new
                {
                    navigateRowList = jsonFilterList,
                    navigateListLength = VisibleLines * (idList - 1) + viewList.Count() - 3,
                    navigateListViewLength = filterList.Count - 3,
                    IdList = idList
                })
                {
                    StatusCode = 200
                });
            }
            catch (Exception e)
            {
                return(new JsonResult(new { message = e.Message })
                {
                    StatusCode = 500
                });
            }
        }