Exemplo n.º 1
0
        /// <summary>
        /// returns all factors of the given FactorTypeId.
        /// </summary>
        /// <param name="reportId"></param>
        /// <param name="factorTypeId">Optional.  Pass a 0 to get all Factors for all types for the given reportId</param>
        /// <param name="filter">Optional.  Filters on FactorScoreDescription</param>
        /// <returns></returns>
        public IList<FactorEntity> FactorGet(int reportId, int factorTypeId, string filter)
        {
            DataTable dt;
            string sql = @"Select f.Id, f.FactorTypeId, fs.Number as FactorScore, fs.Description as FactorScoreDescription, f.Label, f.Title, f.KeyInfo, f.Rationale from Factor f left join FactorScore fs on fs.Id = f.FactorScoreId
            where f.ReportId = @0";
            if (factorTypeId > 0) sql += " and f.FactorTypeId = @1";
            if (filter.Length > 0) sql += " and (f.Title like @2 OR f.KeyInfo like @2)";
            sql += " order by f.Label";
            dt = DB.GetDataTable(new SQLBuilder(sql, reportId.ToString(), factorTypeId.ToString(), "%" + filter + "%"));

            List<FactorEntity> factors = new List<FactorEntity>();
            foreach (DataRow dr in dt.Rows)
            {
                FactorEntity factor = new FactorEntity();
                Framework.EntityPopulate(factor, dr);
                factors.Add(factor);
            }
            return factors;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Returns a single factor
        /// </summary>
        /// <param name="factorId"></param>
        /// <returns></returns>
        public FactorEntity FactorGet(int factorId)
        {
            DataTable dt = DB.GetDataTable(new SQLBuilder(@"Select f.Id, f.FactorTypeId, fs.Number as FactorScore, fs.Description as FactorScoreDescription, f.Label, f.Title, f.KeyInfo, f.Rationale from Factor f left join FactorScore fs on fs.Id = f.FactorScoreId
            where f.Id = @0 order by f.Label", factorId.ToString()));

            if (dt.Rows.Count == 0) return null;

            FactorEntity factor = new FactorEntity();
            Framework.EntityPopulate(factor, dt.Rows[0]);
            return factor;
        }