Пример #1
0
        public string Analy()
        {
            var model = _basicDataService.GetBasicData();

            var currentWeight     = model.BodyWeight;
            var currentHeight     = model.Height;
            var bmi               = float.Parse(ViewModelCommonUtil.CulculateBmi(currentHeight, currentWeight).ToString("0.0000"));
            var appropriateWeight = float.Parse(CulculateAppropriate(currentHeight, currentWeight).ToString("0.0000"));
            var difference        = currentWeight - float.Parse(appropriateWeight.ToString("0.0000"));

            var sb = new StringBuilder();

            sb.AppendLine(LanguageUtils.Get(LanguageKeys.BodyWeightAnalysisFormat1, model.Height.ToString(), appropriateWeight));
            sb.Append(LanguageUtils.Get(LanguageKeys.BodyWeightAnalysisFormat2, difference, bmi));
            sb.Append(LanguageUtils.Get(LanguageKeys.BodyWeightAnalysisFormat3));
            if (difference > 0)
            {
                sb.Append(LanguageUtils.Get(LanguageKeys.BodyWeightAnalysisFormat4));
                sb.Append(LanguageUtils.Get(LanguageKeys.BodyWeightAnalysisFormat8));
            }
            else
            {
                if (bmi < 18.5)
                {
                    sb.Append(LanguageUtils.Get(LanguageKeys.BodyWeightAnalysisFormat7));
                }
                else
                {
                    sb.Append(LanguageUtils.Get(LanguageKeys.BodyWeightAnalysisFormat5));
                }
            }

            return(sb.ToString());
        }
Пример #2
0
        /*----------------------------------------------------------------------------------------------------------------------------------------*/
        //
        // Constractor
        //
        /*----------------------------------------------------------------------------------------------------------------------------------------*/
        #region Constractor

        public InputBasicDataViewModel(IBasicDataService basicDataService)
        {
            try
            {
                _basicDataService = basicDataService;

                InitCommands();
                GenderItemSrouce = new List <GenderEnum>();
                foreach (var gender in Enum.GetValues(typeof(GenderEnum)))
                {
                    GenderItemSrouce.Add((GenderEnum)gender);
                }

                Gender = (int)GenderEnum.未選択;

                var model = _basicDataService.GetBasicData();
                if (model != null)
                {
                    _id               = model.Id;
                    Name              = model.Name;
                    Gender            = model.Gender;
                    Birthday          = model.BirthDay;
                    Height            = model.Height;
                    BodyWeight        = model.BodyWeight;
                    BodyFatPercentage = model.BodyFatPercentage;
                    MaxBloodPressure  = model.MaxBloodPressure;
                    MinBloodPressure  = model.MinBloodPressure;
                    BasalMetabolism   = model.BasalMetabolism;

                    _isUpdate = true;
                }
                else
                {
                    Birthday = DateTime.Parse(ViewModelConst.DefaultTimePick);
                }

                ErrorStack = new ObservableCollection <Xamarin.Forms.View>();
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.StackTrace);
            }
        }