public async Task <IActionResult> GeneralLedger(DataSourceRequest command,
                                                        GlListModel model)
        {
            model.ClientId = (int)_workContext.CurrentCustomer.ClientId;

            var(glListModel, totalCount) = await _financialManagementService.PrepareGLListModel(model, command.Page, command.PageSize);

            var gridModel = new DataSourceResult
            {
                Data  = glListModel.ToList(),
                Total = totalCount
            };

            return(Json(gridModel));
        }
        public async Task <(IEnumerable <GlModel> glItemsModel, int totalCount)> PrepareGLListModel(GlListModel model, int pageIndex, int pageSize)
        {
            SqlParameter[] pr = new SqlParameter[]
            {
                new SqlParameter("@ClientID", model.ClientId)
            };

            var query = await _dbContext.Gl.FromSqlRaw("exec GL_View @ClientID", pr).ToListAsync();

            var glListModel = new List <GlModel>();

            foreach (var item in query)
            {
                if (!string.IsNullOrEmpty(item.Gl1) &&
                    !string.IsNullOrEmpty(item.Gldescription))
                {
                    glListModel.Add(new GlModel
                    {
                        GlID        = item.Glid,
                        GlName      = item.Gl1,
                        Description = item.Gldescription
                    });
                }
            }

            int totalCount = glListModel.Count;
            int pageOffSet = (Convert.ToInt32(pageIndex) - 1) * 10;

            glListModel = glListModel.Skip(pageOffSet).Take(Convert.ToInt32(pageSize)).ToList();

            return(glListModel, totalCount);
        }