Example #1
0
        /// <summary>
        /// Get the filtering for the requirement data table.
        /// </summary>
        /// <param name="dataTableparms">Datatable parameters.</param>
        /// <returns>An filtering expression.</returns>
        private Expression <Func <DTORequirementDataTable, bool> > getFilteringForReqDataTable(DataTableParams dataTableparms)
        {
            Expression <Func <DTORequirementDataTable, bool> > filtering;
            var date = dataTableService.getDateTimeField(dataTableparms.sSearch, DateHp.OnlyDateFormat, "date", ':');

            if (!DateHp.isWholeMinDate(date))
            {
                filtering = (x => DbFunctions.TruncateTime(x.CreationDate) == date.Date);
            }
            else
            {
                filtering = (x =>
                             x.Name.Contains(dataTableparms.sSearch));
            }

            return(filtering);
        }
        /// <summary>
        /// Get json response for datatable as object.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="dataTableParams"></param>
        /// <returns></returns>
        public DataTableJson <DTOProjectDataTable> getDataTableJson(IDbContext context, DataTableParams dataTableParams)
        {
            // Get the records as a list of DTOProjectDataTable
            var projectDataTable = getAll <Project>(context)
                                   .Select(x => new DTOProjectDataTable
            {
                Name                 = x.Name,
                CreationDate         = x.CreationDate,
                Description          = x.Description,
                ProjectId            = x.Id,
                NumberOfTasks        = 0,
                Status               = 0,
                ThereAreRequirements = false
            }).AsQueryable();

            // Get filtering of the global search
            var date = dataTableService.getDateTimeField(dataTableParams.sSearch, DateHp.OnlyDateFormat, "date", ':');
            Expression <Func <DTOProjectDataTable, bool> > filtering;

            if (!DateHp.isWholeMinDate(date))
            {
                filtering = (x => DbFunctions.TruncateTime(x.CreationDate) == date.Date);
            }
            else
            {
                filtering = (x => x.Name.Contains(dataTableParams.sSearch));
            }


            // Get iqueryable source
            var list = dataTableService.getIQueryableSource <DTOProjectDataTable>
                       (
                dataTableParams,
                projectDataTable,
                filtering
                       );

            // Get status
            var listWithStatus = getStatusInListDTOProjectDataTable(context, list);

            return(dataTableService.getJsonResponse <DTOProjectDataTable>(listWithStatus));
        }