/// <summary>
    /// The example below shows how to Select the EnrollmentId and Comments columns for use with a with a Drop Down List, Combo Box, Checked Box List, List View, List Box, etc
    /// </summary>
    private void SelectCourseEnrollmentInfoDropDownListData()
    {
        List <CourseEnrollmentInfo> objCourseEnrollmentInfoCol = CourseEnrollmentInfo.SelectCourseEnrollmentInfoDropDownListData();

        // Example 1:  directly bind to a drop down list - for ASP.NET Web Forms
        // DropDownList ddl1 = new DropDownList();
        // ddl1.DataValueField = "EnrollmentId";
        // ddl1.DataTextField = "Comments";
        // ddl1.DataSource = objCourseEnrollmentInfoCol;
        // ddl1.DataBind();

        // Example 2:  add each item through a loop - for ASP.NET Web Forms
        // DropDownList ddl2 = new DropDownList();

        // foreach (CourseEnrollmentInfo objCourseEnrollmentInfo in objCourseEnrollmentInfoCol)
        // {
        //     ddl2.Items.Add(new ListItem(objCourseEnrollmentInfo.Comments, objCourseEnrollmentInfo.EnrollmentId.ToString()));
        // }

        // Example 3:  bind to a combo box.  for Windows Forms (WinForms)
        // ComboBox cbx1 = new ComboBox();

        // foreach (CourseEnrollmentInfo objCourseEnrollmentInfo in objCourseEnrollmentInfoCol)
        // {
        //     cbx1.Items.Add(new ListItem(objCourseEnrollmentInfo.Comments, objCourseEnrollmentInfo.EnrollmentId.ToString()));
        // }
    }
        public void GetData(string sidx, string sord, int?_page)
        {
            int rows = Functions.GetGridNumberOfRows();
            int numberOfPagesToShow = Functions.GetGridNumberOfPagesToShow();
            int currentPage         = _page is null ? 1 : Convert.ToInt32(_page);
            int startRowIndex       = ((currentPage * rows) - rows);
            int totalRecords        = CourseEnrollmentInfo.GetRecordCount();
            int totalPages          = (int)Math.Ceiling((float)totalRecords / (float)rows);
            List <CourseEnrollmentInfo> objCourseEnrollmentInfoCol = CourseEnrollmentInfo.SelectSkipAndTake(rows, startRowIndex, sidx + " " + sord);

            // fields and titles
            string[,] fieldNames = new string[, ] {
                { "EnrollmentId", "Enrollment Id" },
                { "CourseId", "Course Id" },
                { "StudentId", "Student Id" },
                { "Comments", "Comments" }
            };

            // assign properties
            CourseEnrollmentInfoData       = objCourseEnrollmentInfoCol;
            CourseEnrollmentInfoFieldNames = fieldNames;
            TotalPages           = totalPages;
            CurrentPage          = currentPage;
            FieldToSort          = String.IsNullOrEmpty(sidx) ? "EnrollmentId" : sidx;
            FieldSortOrder       = String.IsNullOrEmpty(sord) ? "asc" : sord;
            FieldToSortWithOrder = String.IsNullOrEmpty(sidx) ? "EnrollmentId" : (sidx + " " + sord).Trim();
            NumberOfPagesToShow  = numberOfPagesToShow;
            StartPage            = Functions.GetPagerStartPage(currentPage, numberOfPagesToShow, totalPages);
            EndPage = Functions.GetPagerEndPage(StartPage, currentPage, numberOfPagesToShow, totalPages);
        }
        /// <summary>
        /// Used when adding or updating a record.
        /// </summary>
        internal static void AddOrEdit(CourseEnrollmentInfo model, CrudOperation operation, bool isForListInline = false)
        {
            CourseEnrollmentInfo objCourseEnrollmentInfo;
            CourseEnrollmentInfo objCourseEnrollmentInfoOld = new CourseEnrollmentInfo();
            decimal id = 0;

            if (operation == CrudOperation.Add)
            {
                objCourseEnrollmentInfo = new CourseEnrollmentInfo();
            }
            else
            {
                objCourseEnrollmentInfo    = CourseEnrollmentInfo.SelectByPrimaryKey(model.EnrollmentId);
                objCourseEnrollmentInfoOld = objCourseEnrollmentInfo.ShallowCopy();
            }

            objCourseEnrollmentInfo.EnrollmentId = model.EnrollmentId;
            objCourseEnrollmentInfo.CourseId     = model.CourseId;
            objCourseEnrollmentInfo.StudentId    = model.StudentId;
            objCourseEnrollmentInfo.Comments     = model.Comments;

            if (operation == CrudOperation.Add)
            {
                id = objCourseEnrollmentInfo.Insert();
            }
            else
            {
                objCourseEnrollmentInfo.Update();
            }
        }
    /// <summary>
    /// Shows how to Select a record by Primary Key.  It also shows how to retrieve Lazily-loaded related Objects.  Related Objects are assigned for each Foreign Key.
    /// </summary>
    private void SelectByPrimaryKey()
    {
        int enrollmentIdSample = 12;

        // select a record by primary key(s)

        CourseEnrollmentInfo objCourseEnrollmentInfo = CourseEnrollmentInfo.SelectByPrimaryKey(enrollmentIdSample);

        if (objCourseEnrollmentInfo != null)
        {
            // if record is found, a record is returned
            int    enrollmentId = objCourseEnrollmentInfo.EnrollmentId;
            int    courseId     = objCourseEnrollmentInfo.CourseId;
            int    studentId    = objCourseEnrollmentInfo.StudentId;
            string comments     = objCourseEnrollmentInfo.Comments;

            // get the CourseEnrollmentInfo related to EnrollmentId.
            CourseEnrollmentInfo objCourseEnrollmentInfoRelatedToEnrollmentId = CourseEnrollmentInfo.SelectByPrimaryKey(enrollmentId);

            // get the Course related to CourseId.
            Course objCourseRelatedToCourseId = Course.SelectByPrimaryKey(courseId);

            // get the Student related to StudentId.
            Student objStudentRelatedToStudentId = Student.SelectByPrimaryKey(studentId);
        }
    }
        /// <summary>
        /// Gets the list of data for use by the jqgrid plug-in
        /// </summary>
        public IActionResult OnGetGridData(string sidx, string sord, int _page, int rows, bool isforJqGrid = true)
        {
            int totalRecords  = CourseEnrollmentInfo.GetRecordCount();
            int startRowIndex = ((_page * rows) - rows);
            List <CourseEnrollmentInfo> objCourseEnrollmentInfoCol = CourseEnrollmentInfo.SelectSkipAndTake(rows, startRowIndex, sidx + " " + sord);
            int totalPages = (int)Math.Ceiling((float)totalRecords / (float)rows);

            if (objCourseEnrollmentInfoCol is null)
            {
                return(new JsonResult("{ total = 0, page = 0, records = 0, rows = null }"));
            }

            var jsonData = new
            {
                total = totalPages,
                _page,
                records = totalRecords,
                rows    = (
                    from objCourseEnrollmentInfo in objCourseEnrollmentInfoCol
                    select new
                {
                    id = objCourseEnrollmentInfo.EnrollmentId,
                    cell = new string[] {
                        objCourseEnrollmentInfo.EnrollmentId.ToString(),
                        objCourseEnrollmentInfo.CourseId.ToString(),
                        objCourseEnrollmentInfo.StudentId.ToString(),
                        objCourseEnrollmentInfo.Comments
                    }
                }).ToArray()
            };

            return(new JsonResult(jsonData));
        }
    /// <summary>
    /// Shows how to get a specific number of sorted records, starting from an index, based on Search Parameters.  The number of records are also retrieved.
    /// </summary>
    private void SelectSkipAndTakeDynamicWhere()
    {
        int    startRetrievalFromRecordIndex = 0;
        int    numberOfRecordsToRetrieve     = 10;
        string sortBy = "EnrollmentId";
        //string sortBy = "EnrollmentId desc";

        // search parameters, everything is nullable, only items being searched for should be filled
        // note: fields with String type uses a LIKE search, everything else uses an exact match
        // also, every field you're searching for uses the AND operator
        // e.g. int? productID = 1; string productName = "ch";
        // will translate to: SELECT....WHERE productID = 1 AND productName LIKE '%ch%'
        int?   enrollmentId = null;
        int?   courseId     = null;
        int?   studentId    = null;
        string comments     = null;

        // 1. select a specific number of sorted records starting from the index you specify based on Search Parameters
        List <CourseEnrollmentInfo> objCourseEnrollmentInfoCol = CourseEnrollmentInfo.SelectSkipAndTakeDynamicWhere(enrollmentId, courseId, studentId, comments, numberOfRecordsToRetrieve, startRetrievalFromRecordIndex, sortBy);

        // to use objCourseEnrollmentInfoCol please see the SelectAll() method examples
        // No need for Examples 1 and 2 because the Collection here is already sorted
        // Example 3:  directly bind to a GridView - for ASP.NET Web Forms
        // Example 4:  loop through all the CourseEnrollmentInfo(s).  The example above will only loop for 10 items.
    }
Пример #7
0
        /// <summary>
        /// Handler, updates a record.
        /// </summary>
        public IActionResult OnGetUpdate(string serializedData)
        {
            CourseEnrollmentInfo objCourseEnrollmentInfo = JsonConvert.DeserializeObject <CourseEnrollmentInfo>(serializedData);

            CourseEnrollmentInfoFunctions.AddOrEdit(objCourseEnrollmentInfo, CrudOperation.Update, true);
            return(new JsonResult(true));
        }
Пример #8
0
        /// <summary>
        /// Handler, deletes a record.
        /// </summary>
        public IActionResult OnGetRemove(int id)
        {
            CourseEnrollmentInfo CourseEnrollmentInfo = CourseEnrollmentInfo.SelectByPrimaryKey(id);

            CourseEnrollmentInfo.Delete(id);
            return(new JsonResult(true));
        }
    /// <summary>
    /// Shows how to Select all records.  It also shows how to sort, bind, and loop through records.
    /// </summary>
    private void SelectAll()
    {
        // select all records
        List <CourseEnrollmentInfo> objCourseEnrollmentInfoCol = CourseEnrollmentInfo.SelectAll();

        // Example 1:  you can optionally sort the collection in ascending order by your chosen field
        objCourseEnrollmentInfoCol.Sort(CourseEnrollmentInfo.ByCourseId);

        // Example 2:  to sort in descending order, add this line to the Sort code in Example 1
        objCourseEnrollmentInfoCol.Reverse();

        // Example 3:  directly bind to a GridView - for ASP.NET Web Forms
        // GridView grid = new GridView();
        // grid.DataSource = objCourseEnrollmentInfoCol;
        // grid.DataBind();

        // Example 4:  loop through all the CourseEnrollmentInfo(s)
        foreach (CourseEnrollmentInfo objCourseEnrollmentInfo in objCourseEnrollmentInfoCol)
        {
            int    enrollmentId = objCourseEnrollmentInfo.EnrollmentId;
            int    courseId     = objCourseEnrollmentInfo.CourseId;
            int    studentId    = objCourseEnrollmentInfo.StudentId;
            string comments     = objCourseEnrollmentInfo.Comments;

            // get the CourseEnrollmentInfo related to EnrollmentId.
            CourseEnrollmentInfo objCourseEnrollmentInfoRelatedToEnrollmentId = CourseEnrollmentInfo.SelectByPrimaryKey(enrollmentId);

            // get the Course related to CourseId.
            Course objCourseRelatedToCourseId = Course.SelectByPrimaryKey(courseId);

            // get the Student related to StudentId.
            Student objStudentRelatedToStudentId = Student.SelectByPrimaryKey(studentId);
        }
    }
    /// <summary>
    /// Shows how to Select all records sorted by column name in either ascending or descending order.
    /// </summary>
    private void SelectAllWithSortExpression()
    {
        // select all records sorted by EnrollmentId in ascending order
        string sortBy = "EnrollmentId"; // ascending order
        //string sortBy = "EnrollmentId desc"; // descending order

        List <CourseEnrollmentInfo> objCourseEnrollmentInfoCol = CourseEnrollmentInfo.SelectAll(sortBy);
    }
    /// <summary>
    /// Shows how to Select all records by Student, related to column StudentId sorted by column name in either ascending or descending order.
    /// </summary>
    private void SelectCourseEnrollmentInfoCollectionByStudentIdWithSortExpression()
    {
        int    studentIdSample = 12;
        string sortBy          = "EnrollmentId"; // ascending order
        //string sortBy = "EnrollmentId desc"; // descending order

        List <CourseEnrollmentInfo> objCourseEnrollmentInfoCol = CourseEnrollmentInfo.SelectCourseEnrollmentInfoCollectionByStudentId(studentIdSample, sortBy);
    }
Пример #12
0
        /// <summary>
        /// Updates a record
        /// </summary>
        internal static void Update(CourseEnrollmentInfo objCourseEnrollmentInfo)
        {
            CourseEnquiryDBContext context = new CourseEnquiryDBContext();
            CourseEnrollmentInfo   entCourseEnrollmentInfo = context.CourseEnrollmentInfo.Where(c => c.EnrollmentId == objCourseEnrollmentInfo.EnrollmentId).FirstOrDefault();

            if (entCourseEnrollmentInfo != null)
            {
                entCourseEnrollmentInfo.CourseId  = objCourseEnrollmentInfo.CourseId;
                entCourseEnrollmentInfo.StudentId = objCourseEnrollmentInfo.StudentId;
                entCourseEnrollmentInfo.Comments  = objCourseEnrollmentInfo.Comments;

                context.SaveChanges();
            }
        }
    /// <summary>
    /// Shows how to get all records based on Search Parameters.
    /// </summary>
    private void SelectAllDynamicWhere()
    {
        // search parameters, everything is nullable, only items being searched for should be filled
        // note: fields with String type uses a LIKE search, everything else uses an exact match
        // also, every field you're searching for uses the AND operator
        // e.g. int? productID = 1; string productName = "ch";
        // will translate to: SELECT....WHERE productID = 1 AND productName LIKE '%ch%'
        int?   enrollmentId = null;
        int?   courseId     = null;
        int?   studentId    = null;
        string comments     = null;

        List <CourseEnrollmentInfo> objCourseEnrollmentInfoCol = CourseEnrollmentInfo.SelectAllDynamicWhere(enrollmentId, courseId, studentId, comments);
    }
    /// <summary>
    /// Shows how to get a specific number of sorted records, starting from an index.  The total number of records are also retrieved when using the SelectSkipAndTake() method.
    /// For example, if there are 200 records take only 10 records (numberOfRecordsToRetrieve), starting from the first index (startRetrievalFromRecordIndex = 0)
    /// The example below uses some variables, here are their definitions:
    /// totalRecordCount - total number of records if you were to retrieve everything
    /// startRetrievalFromRecordIndex - the index to start taking records from. Zero (0) E.g. If you want to skip the first 20 records, then assign 19 here.
    /// numberOfRecordsToRetrieve - take n records starting from the startRetrievalFromRecordIndex
    /// sortBy - to sort in Ascending order by Field Name, just assign just the Field Name, do not pass 'asc'
    /// sortBy - to sort in Descending order by Field Name, use the Field Name, a space and the word 'desc'
    /// </summary>
    private void SelectSkipAndTake()
    {
        int    startRetrievalFromRecordIndex = 0;
        int    numberOfRecordsToRetrieve     = 10;
        string sortBy = "EnrollmentId";
        //string sortBy = "EnrollmentId desc";

        // 1. select a specific number of sorted records starting from the index you specify
        List <CourseEnrollmentInfo> objCourseEnrollmentInfoCol = CourseEnrollmentInfo.SelectSkipAndTake(numberOfRecordsToRetrieve, startRetrievalFromRecordIndex, sortBy);

        // to use objCourseEnrollmentInfoCol please see the SelectAll() method examples
        // No need for Examples 1 and 2 because the Collection here is already sorted
        // Example 2:  directly bind to a GridView - for ASP.NET Web Forms
        // Example 3:  loop through all the CourseEnrollmentInfo(s).  The example above will only loop for 10 items.
    }
Пример #15
0
        /// <summary>
        /// Inserts a record
        /// </summary>
        internal static int Insert(CourseEnrollmentInfo objCourseEnrollmentInfo)
        {
            CourseEnquiryDBContext context = new CourseEnquiryDBContext();
            CourseEnrollmentInfo   entCourseEnrollmentInfo = new CourseEnrollmentInfo();

            entCourseEnrollmentInfo.EnrollmentId = objCourseEnrollmentInfo.EnrollmentId;
            entCourseEnrollmentInfo.CourseId     = objCourseEnrollmentInfo.CourseId;
            entCourseEnrollmentInfo.StudentId    = objCourseEnrollmentInfo.StudentId;
            entCourseEnrollmentInfo.Comments     = objCourseEnrollmentInfo.Comments;

            context.CourseEnrollmentInfo.Add(entCourseEnrollmentInfo);
            context.SaveChanges();

            return(entCourseEnrollmentInfo.EnrollmentId);
        }
    /// <summary>
    /// Shows how to Insert or Create a New Record
    /// </summary>
    private void Insert()
    {
        // first instantiate a new CourseEnrollmentInfo
        CourseEnrollmentInfo objCourseEnrollmentInfo = new CourseEnrollmentInfo();

        // assign values you want inserted
        objCourseEnrollmentInfo.EnrollmentId = 12;
        objCourseEnrollmentInfo.CourseId     = 12;
        objCourseEnrollmentInfo.StudentId    = 12;
        objCourseEnrollmentInfo.Comments     = "abc";

        // finally, insert a new record
        // the insert method returns the newly created primary key
        int newlyCreatedPrimaryKey = objCourseEnrollmentInfo.Insert();
    }
    /// <summary>
    /// Shows how to Update an existing record by Primary Key
    /// </summary>
    private void Update()
    {
        // first instantiate a new CourseEnrollmentInfo
        CourseEnrollmentInfo objCourseEnrollmentInfo = new CourseEnrollmentInfo();

        // assign the existing primary key(s)
        // of the record you want updated
        objCourseEnrollmentInfo.EnrollmentId = 12;

        // assign values you want updated
        objCourseEnrollmentInfo.CourseId  = 12;
        objCourseEnrollmentInfo.StudentId = 12;
        objCourseEnrollmentInfo.Comments  = "abc";

        // finally, update an existing record
        objCourseEnrollmentInfo.Update();
    }
Пример #18
0
        private PageResult LoadPage(string returnUrl)
        {
            // create the model used by the partial page
            AddEditCourseEnrollmentInfoPartialModel model = new AddEditCourseEnrollmentInfoPartialModel();

            model.CourseEnrollmentInfoDropDownListData = CourseEnrollmentInfo.SelectCourseEnrollmentInfoDropDownListData();
            model.CourseDropDownListData  = Course.SelectCourseDropDownListData();
            model.StudentDropDownListData = Student.SelectStudentDropDownListData();
            model.Operation = CrudOperation.Add;
            model.ReturnUrl = returnUrl;

            // assign values to the model used by this page
            PartialModel = model;

            // assign the return url
            ReturnUrl = returnUrl;

            return(Page());
        }
        /// <summary>
        /// Gets the list of data for use by the jqgrid plug-in
        /// </summary>
        public IActionResult OnGetGridDataGroupedByEnrollmentId(string sidx, string sord, int _page, int rows)
        {
            // using a groupField in the jqgrid passes that field
            // along with the field to sort, remove the groupField
            string groupBy = "Comments asc, ";

            sidx = sidx.Replace(groupBy, "");

            int totalRecords  = CourseEnrollmentInfo.GetRecordCount();
            int startRowIndex = ((_page * rows) - rows);

            List <CourseEnrollmentInfo> objCourseEnrollmentInfoCol = CourseEnrollmentInfo.SelectSkipAndTake(rows, startRowIndex, sidx + " " + sord);
            int totalPages = (int)Math.Ceiling((float)totalRecords / (float)rows);

            if (objCourseEnrollmentInfoCol is null)
            {
                return(new JsonResult("{ total = 0, page = 0, records = 0, rows = null }"));
            }

            var jsonData = new
            {
                total = totalPages,
                _page,
                records = totalRecords,
                rows    = (
                    from objCourseEnrollmentInfo in objCourseEnrollmentInfoCol
                    select new
                {
                    id = objCourseEnrollmentInfo.EnrollmentId,
                    cell = new string[] {
                        objCourseEnrollmentInfo.EnrollmentId.ToString(),
                        objCourseEnrollmentInfo.CourseId.ToString(),
                        objCourseEnrollmentInfo.StudentId.ToString(),
                        objCourseEnrollmentInfo.Comments,
                        objCourseEnrollmentInfo.CourseEnrollmentInfo1.Comments
                    }
                }).ToArray()
            };

            return(new JsonResult(jsonData));
        }
        public PageResult LoadPage(int id, string returnUrl)
        {
            // select a record by primary key(s)
            CourseEnquiryAPI.BusinessObject.CourseEnrollmentInfo objCourseEnrollmentInfo = CourseEnrollmentInfo.SelectByPrimaryKey(id);

            // create the model used by the partial page
            AddEditCourseEnrollmentInfoPartialModel model = new AddEditCourseEnrollmentInfoPartialModel();

            model.CourseEnrollmentInfoDropDownListData = CourseEnrollmentInfo.SelectCourseEnrollmentInfoDropDownListData();
            model.CourseDropDownListData  = Course.SelectCourseDropDownListData();
            model.StudentDropDownListData = Student.SelectStudentDropDownListData();
            model.Operation            = CrudOperation.Update;
            model.ReturnUrl            = returnUrl;
            model.CourseEnrollmentInfo = objCourseEnrollmentInfo;

            // assign values to the model used by this page
            PartialModel = model;

            // assign the return url
            ReturnUrl = returnUrl;

            return(Page());
        }
Пример #21
0
        /// <summary>
        /// Updates a record
        /// </summary>
        public void Update()
        {
            CourseEnrollmentInfo objCourseEnrollmentInfo = (CourseEnrollmentInfo)this;

            CourseEnrollmentInfoDataLayer.Update(objCourseEnrollmentInfo);
        }
Пример #22
0
        /// <summary>
        /// Inserts a record
        /// </summary>
        public int Insert()
        {
            CourseEnrollmentInfo objCourseEnrollmentInfo = (CourseEnrollmentInfo)this;

            return(CourseEnrollmentInfoDataLayer.Insert(objCourseEnrollmentInfo));
        }
 /// <summary>
 /// Shows how to Delete an existing record by Primary Key
 /// </summary>
 private void Delete()
 {
     // delete a record by primary key
     CourseEnrollmentInfo.Delete(12);
 }
 /// <summary>
 /// Shows how to get the total number of records
 /// </summary>
 private void GetRecordCount()
 {
     // get the total number of records in the CourseEnrollmentInfo table
     int totalRecordCount = CourseEnrollmentInfo.GetRecordCount();
 }
        public void LoadPage(int id, string returnUrl)
        {
            // select a record by primary key(s)
            CourseEnquiryAPI.BusinessObject.CourseEnrollmentInfo objCourseEnrollmentInfo = CourseEnrollmentInfo.SelectByPrimaryKey(id);

            // assign values to this page's bound property
            CourseEnrollmentInfo = objCourseEnrollmentInfo;

            // assign the return url
            ReturnUrl = returnUrl;
        }
 /// <summary>
 /// Shows how to get the total number of records by StudentId
 /// </summary>
 private void GetRecordCountByStudentId()
 {
     // get the total number of records in the CourseEnrollmentInfo table by StudentId
     // 12 here is just a sample StudentId change the value as you see fit
     int totalRecordCount = CourseEnrollmentInfo.GetRecordCountByStudentId(12);
 }
        /// <summary>
        /// Gets the list of data for use by the jqgrid plug-in
        /// </summary>
        public IActionResult OnGetGridDataWithFilters(string sidx, string sord, int _page, int rows, string filters)
        {
            int?   enrollmentId = null;
            int?   courseId     = null;
            int?   studentId    = null;
            string comments     = String.Empty;

            if (!String.IsNullOrEmpty(filters))
            {
                // deserialize json and get values being searched
                var jsonResult = JsonConvert.DeserializeObject <Dictionary <string, dynamic> >(filters);

                foreach (var rule in jsonResult["rules"])
                {
                    if (rule["field"].Value.ToLower() == "enrollmentid")
                    {
                        enrollmentId = Convert.ToInt32(rule["data"].Value);
                    }

                    if (rule["field"].Value.ToLower() == "courseid")
                    {
                        courseId = Convert.ToInt32(rule["data"].Value);
                    }

                    if (rule["field"].Value.ToLower() == "studentid")
                    {
                        studentId = Convert.ToInt32(rule["data"].Value);
                    }

                    if (rule["field"].Value.ToLower() == "comments")
                    {
                        comments = rule["data"].Value;
                    }
                }

                // sometimes jqgrid assigns a -1 to numeric fields when no value is assigned
                // instead of assigning a null, we'll correct this here
                if (enrollmentId == -1)
                {
                    enrollmentId = null;
                }

                if (courseId == -1)
                {
                    courseId = null;
                }

                if (studentId == -1)
                {
                    studentId = null;
                }
            }

            int totalRecords  = CourseEnrollmentInfo.GetRecordCountDynamicWhere(enrollmentId, courseId, studentId, comments);
            int startRowIndex = ((_page * rows) - rows);
            List <CourseEnrollmentInfo> objCourseEnrollmentInfoCol = CourseEnrollmentInfo.SelectSkipAndTakeDynamicWhere(enrollmentId, courseId, studentId, comments, rows, startRowIndex, sidx + " " + sord);
            int totalPages = (int)Math.Ceiling((float)totalRecords / (float)rows);

            if (objCourseEnrollmentInfoCol is null)
            {
                return(new JsonResult("{ total = 0, page = 0, records = 0, rows = null }"));
            }

            var jsonData = new
            {
                total = totalPages,
                _page,
                records = totalRecords,
                rows    = (
                    from objCourseEnrollmentInfo in objCourseEnrollmentInfoCol
                    select new
                {
                    id = objCourseEnrollmentInfo.EnrollmentId,
                    cell = new string[] {
                        objCourseEnrollmentInfo.EnrollmentId.ToString(),
                        objCourseEnrollmentInfo.CourseId.ToString(),
                        objCourseEnrollmentInfo.StudentId.ToString(),
                        objCourseEnrollmentInfo.Comments
                    }
                }).ToArray()
            };

            return(new JsonResult(jsonData));
        }
 /// <summary>
 /// Initial handler the razor page encounters.
 /// </summary>
 public void OnGet()
 {
     CourseEnrollmentInfoDropDownListData = CourseEnrollmentInfo.SelectCourseEnrollmentInfoDropDownListData();
     CourseDropDownListData  = Course.SelectCourseDropDownListData();
     StudentDropDownListData = Student.SelectStudentDropDownListData();
 }