示例#1
0
        /// <summary>
        /// 3回の平均というビジネスロジックを追加している
        /// </summary>
        /// <returns></returns>
        public MeasureEntity GetLatest()
        {
            var val1 = _repository.GetLatest();

            // データが無ければ例外
            if (val1 == null)
            {
                throw new DataNotExistsException();
            }

            System.Threading.Thread.Sleep(10);
            var val2 = _repository.GetLatest();

            System.Threading.Thread.Sleep(10);
            var val3 = _repository.GetLatest();

            System.Threading.Thread.Sleep(10);

            var sum =
                val1.MeasureValue.Value +
                val2.MeasureValue.Value +
                val3.MeasureValue.Value;
            var ave = sum / 3f;

            return(new MeasureEntity(
                       val3.AreaId.Value,
                       val3.MeasureDate.Value,
                       ave));
        }
示例#2
0
        /// <summary>
        /// サーチ処理
        /// </summary>
        public void Search()
        {
            // ①インターフェース
            var measure = _measureRepository.GetLatest();

            // ②具象クラス
            //var measure = Measures.GetLatest( new AreaId(10));

            // データが無ければ例外
            if (measure == null)
            {
                throw new DataNotExistsException();
            }

            // AreaIdText = measure.AreaId.ToString().PadLeft(4, '0');
            // ValueObject化
            // Objectを指定
            AreaIdText = measure.AreaId.DisplayValue;

            // MeasureDateText = measure.MeasureDate.ToString("yyyy/MM/dd HH:mm:ss");
            MeasureDateText = measure.MeasureDate.DisplayValue;

            // MeasureValueText = Math.Round(measure.MeasureValue, 2) + "℃";
            MeasureValueText = measure.MeasureValue.DisplayValue;
        }
示例#3
0
        public LatestViewModel(IMeasureRepository measureRepository)
        {
            _measureRepository = measureRepository;
            var entity = _measureRepository.GetLatest();

            MeasureDate  = entity.MeasureDate.DisplayValue;
            MeasureValue = entity.MeasureValue.DisplayValue;
        }
示例#4
0
        public void Search()
        {
            MeasureEntity entity = _measureRepository.GetLatest();

            AreaIDText       = entity.AreaID.ToString().PadLeft(4, '0');
            MeasureDateText  = entity.MeasureDate.ToString("yyyy/MM/dd hh:mm:ss");
            MeasureValueText = Math.Round(entity.MeasureValue, 2) + "℃";
        }
示例#5
0
        public LatestViewModel(IMeasureRepository measureRepository)
        {
            _measureRepository = measureRepository ?? throw new ArgumentNullException(nameof(measureRepository));

            var entity = _measureRepository.GetLatest();

            MeasureDate  = entity.MeasureDate.DisplayValue;
            MeasureValue = entity.MeasureValue.DisplayValue;
        }