コード例 #1
0
        //main function to create fake database with no goals
        private Result GetJsonResultNoGoals(int mID, decimal currentMonthDataPoint, int dataPointID_1, short hasGoal, int dataType)
        {
            string name = "This is a name of a measurement";
            DateTime now = DateTime.Now;

            JsonResult jsonResult = new JsonResult();

            List<DataPointViewModel> getMeasurementDataPointsList = new List<DataPointViewModel>();
            DataPointViewModel dataPoint = new DataPointViewModel();
            dataPoint.MeasurementID = mID;
            dataPoint.NameMeasurement = name;
            dataPoint.DataPointID = dataPointID_1;
            dataPoint.Applicable = now;
            dataPoint.Value = currentMonthDataPoint;
            dataPoint.NumType = dataType;
            getMeasurementDataPointsList.Add(dataPoint);

            List<BasicMeasurementData> getInfoHasGoal = new List<BasicMeasurementData>();
            BasicMeasurementData basicMeasurementData = new BasicMeasurementData();
            basicMeasurementData.MeasurementID = mID;
            basicMeasurementData.NameMeasurement = name;
            basicMeasurementData.HasGoal = hasGoal;
            getInfoHasGoal.Add(basicMeasurementData);

            List<GoalDataViewModel> getGoalData = new List<GoalDataViewModel>();

            _repository.Expect(x => x.GetInfoHasGoal(Arg<int>.Is.Anything)).Return(getInfoHasGoal);
            _repository.Expect(x => x.GetGoalData(Arg<int>.Is.Anything)).Return(getGoalData);
            _repository.Expect(x => x.GetMeasurementDataPoints(Arg<int>.Is.Anything, Arg<DateTime>.Is.Anything, Arg<DateTime>.Is.Anything)).Return(getMeasurementDataPointsList);
            _mocks.ReplayAll();

            jsonResult = _controller.GetMeasurementData(mID);
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            Result result = serializer.Deserialize<Result>(serializer.Serialize(jsonResult.Data));
            return result;
        }
コード例 #2
0
 /// <summary>
 /// Creates a new instance of the DDatapoint class
 /// </summary>
 /// <param name="parent">DMeasurement hosting this DDatapoint</param>
 /// <param name="model">Model providng data for this DDatapoint</param>
 public DDatapoint(DMeasurement parent, Datapoint model)
 {
     this.Parent = parent;
     this.db = parent.db;
     this.Model = model;
     ViewModel = new DataPointViewModel();
     ViewModel.MeasurementID = Parent.Model.Measurement_ID;
     ViewModel.NameMeasurement = Parent.Model.NM;
     ViewModel.YTDCalc = Parent.Model.YTD_Calc;
     ViewModel.DataPointID = model.Datapoint_ID;
     ViewModel.Applicable = model.Applicable_DT;
     ViewModel.Value = model.Value_AMT;
     ViewModel.NumType = Parent.Model.Type_ID;
     ViewModel.IsCalculated = Parent.Model.Is_Calculated;
     ViewModel.HasSubmitted = model.HasSubmitted_IN;
     string roundingString = "";
     var decimalPlaces = (from m in db.Measurements
                          where Parent.Model.Measurement_ID == m.Measurement_ID
                          select m.Decimal_Points_SZ).ToList();
     var roundingInt = (int)(decimalPlaces.Count > 0 ? decimalPlaces.First() : 0);
     if (roundingInt != 0)
     {
         roundingString = ".";
         for (var i = 0; i < roundingInt; i++)
             roundingString += "0";
     }
     ViewModel.RoudingString = roundingString;
 }