Example #1
0
        public static List <KPIMeasurement> GetKpiMeasurementsByKpiOwner(int ownerId, string ownerType, string userName, ref decimal maxValue, ref decimal minValue)
        {
            if (ownerId <= 0)
            {
                throw new ArgumentException("ownerId cannot be equals or less than zero");
            }
            if (string.IsNullOrEmpty(ownerType))
            {
                throw new ArgumentException("ownerType cannot be null or empty");
            }
            if (string.IsNullOrEmpty(userName))
            {
                throw new ArgumentException("userName cannot be null or empty");
            }

            decimal?max = 0;
            decimal?min = 0;

            KpiMeasurementDSTableAdapters.KpiMeasurementTableAdapter adapter = new KpiMeasurementDSTableAdapters.KpiMeasurementTableAdapter();
            KpiMeasurementDS.KpiMeasurementDataTable table = adapter.GetKpiMeasurementsByKpiOwner(ownerId, ownerType, userName, ref min, ref max);
            maxValue = max == null ? 0 : max.Value;
            minValue = min == null ? 0 : min.Value;

            List <KPIMeasurement> list = new List <KPIMeasurement>();

            foreach (var row in table)
            {
                list.Add(new KPIMeasurement()
                {
                    KPIID       = row.kpiID,
                    Date        = row.date,
                    Measurement = row.measurement
                });
            }

            return(list);
        }