Beispiel #1
0
        public void MetricValueDateKeyKeyWorksWithNullValue()
        {
            var metricValue = new Rock.Model.MetricValue();

            metricValue.MetricValueDateTime = null;
            Assert.IsNull(metricValue.MetricValueDateKey);
        }
Beispiel #2
0
        protected void btnSaveValue_Click(object sender, EventArgs e)
        {
            using (new Rock.Data.UnitOfWorkScope())
            {
                int metricValueId = (hfIdValue.Value) != null?Int32.Parse(hfIdValue.Value) : 0;

                var metricValueService = new Rock.Model.MetricValueService();
                Rock.Model.MetricValue metricValue;

                if (metricValueId == 0)
                {
                    metricValue          = new Rock.Model.MetricValue();
                    metricValue.IsSystem = false;
                    metricValue.MetricId = Int32.Parse(hfIdMetric.Value);
                    metricValueService.Add(metricValue, CurrentPersonId);
                }
                else
                {
                    metricValue = metricValueService.Get(metricValueId);
                }

                metricValue.Value       = tbValue.Text;
                metricValue.Description = tbValueDescription.Text;
                metricValue.xValue      = tbXValue.Text;
                metricValue.Label       = tbLabel.Text;
                metricValue.isDateBased = cbIsDateBased.Checked;
                metricValue.MetricId    = Int32.Parse(ddlMetricFilter.SelectedValue);
                metricValueService.Save(metricValue, CurrentPersonId);
            }

            BindGridValue();

            modalValue.Hide();
            pnlValueList.Visible = true;
        }
Beispiel #3
0
        private Rock.Model.MetricValue BuildMetricValue(RockContext rockContext, DateTime requestDate)
        {
            var metric      = new MetricService(rockContext).Queryable().First();
            var metricValue = new Rock.Model.MetricValue();

            metricValue.ForeignKey          = metricValueForeignKey;
            metricValue.MetricValueDateTime = requestDate;
            metricValue.MetricId            = metric.Id;

            return(metricValue);
        }
Beispiel #4
0
        public void MetricValueDateKeyGetsSetCorrectly()
        {
            var testList = TestDataHelper.GetAnalyticsSourceDateTestData();

            foreach (var keyValue in testList)
            {
                var metricValue = new Rock.Model.MetricValue();
                metricValue.MetricValueDateTime = keyValue.Value;
                Assert.AreEqual(keyValue.Key, metricValue.MetricValueDateKey);
            }
        }
Beispiel #5
0
        protected void rGridValue_Delete(object sender, RowEventArgs e)
        {
            var metricValueService = new Rock.Model.MetricValueService();

            Rock.Model.MetricValue metricValue = metricValueService.Get((int)rGridValue.DataKeys[e.RowIndex]["id"]);
            if (metricValue != null)
            {
                metricValueService.Delete(metricValue, CurrentPersonId);
                metricValueService.Save(metricValue, CurrentPersonId);
            }

            BindGridValue();
        }
Beispiel #6
0
 /// <summary>
 /// Instantiates a new DTO object from the entity
 /// </summary>
 /// <param name="metricValue"></param>
 public MetricValueDto(MetricValue metricValue)
 {
     CopyFromModel(metricValue);
 }
Beispiel #7
0
 /// <summary>
 /// To the dto.
 /// </summary>
 /// <param name="value">The value.</param>
 /// <returns></returns>
 public static MetricValueDto ToDto(this MetricValue value)
 {
     return(new MetricValueDto(value));
 }