Beispiel #1
0
        /// <summary>
        /// Get json datatable for requirements.
        /// </summary>
        /// <param name="context">Context of the database.</param>
        /// <param name="requirement">Requirement that contains the projectId</param>
        /// <param name="dataTableparms"></param>
        /// <returns></returns>
        public DataTableJson <DTORequirementDataTable> getJsonDataTable(IDbContext context, DTORequirements requirement, DataTableParams dataTableparms)
        {
            // Get requirement as a list of DTORequirementDataTable
            var requirementsDataTable = getAllByProjectId(context, requirement)
                                        .Select(x => new DTORequirementDataTable
            {
                RequirementId = x.Id,
                ProjectId     = x.ProjectId,
                CreationDate  = x.CreationDate,
                Description   = x.Description,
                Name          = x.Name,
                NumberOfTasks = 0,
                ThereAreTasks = false
            }).AsQueryable();

            // Get the filtering
            Expression <Func <DTORequirementDataTable, bool> > filtering = getFilteringForReqDataTable(dataTableparms);

            // Get json
            var iqueryableSource = dataTableService.getIQueryableSource <DTORequirementDataTable>
                                   (
                dataTableparms,
                requirementsDataTable,
                filtering
                                   );

            // Get status
            var listWithStatus = getStatusInListDTORequirementDataTable(context, iqueryableSource);

            // Return json response
            return(dataTableService.getJsonResponse <DTORequirementDataTable>(listWithStatus));
        }
        /// <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));
        }