Example #1
0
        public JsonResult Sessions([FromBody] Pagination pagination)
        {
            if (pagination != null)
            {
                var results = _formationService.GetSessions();
                if (!String.IsNullOrEmpty(pagination.Search))
                {
                    results = _formationService.GetSessions().Where(i => i.Formation.Titre.Contains(pagination.Search));
                }
                int totalRows = results.Count();
                Util.Paginate <Session>(pagination, ref results);

                var rows = results.ToList();
                var filteredTotalRows = rows.Count();

                return(Json(new
                {
                    Rows = rows,
                    FilteredTotalRows = filteredTotalRows,
                    TotalRows = totalRows
                }));
            }
            else
            {
                return(Json(new
                {
                    Rows = new List <Session>(),
                    FilteredTotalRows = 0,
                    TotalRows = 0
                }));
            }
        }