Exemple #1
0
        public IActionResult LoadViewComponentUserTracking(UserTrackingFilter model)
        {
            if (model.MeasurementScale == null)
            {
                model.MeasurementScale = new Scale(_lookupAppService);
            }
            string measurementScaleConst = string.Empty;

            if (model.MeasurementScaleLKDId == 0)
            {
                if (model.BodyPart == EnumUserTrackingBodyPart.Height)
                {
                    measurementScaleConst = LookUpDetailConst.Cm;
                }
                else if (model.BodyPart == EnumUserTrackingBodyPart.Weight)
                {
                    measurementScaleConst = LookUpDetailConst.Kg;
                }
                else
                {
                    measurementScaleConst = LookUpDetailConst.Cm;
                }
                model.MeasurementScaleLKDId = _lookupAppService.GetAllLookDetail(null, measurementScaleConst).Result.Items.First().Id;
            }
            return(ViewComponent("UserTrackingDetailTab", model));
        }
        public async Task <IViewComponentResult> InvokeAsync(UserTrackingFilter model)
        {
            //Decrypt UserId
            model.UserId = Convert.ToInt32(CryptoEngine.DecryptString(model.UserIdEnyc));
            var userTrackingDtoList = _userTrackingAppService.GetAllUserTrackingList(model);
            var user = userTrackingDtoList.FirstOrDefault()?.User;

            //Scale
            if (model.BodyPart == EnumUserTrackingBodyPart.Height)
            {
                model.MeasurementScale.ScaleHeight.Find(x => x.Value == model.MeasurementScaleLKDId.ToString()).Selected = true;
            }
            else if (model.BodyPart == EnumUserTrackingBodyPart.Weight)
            {
                model.MeasurementScale.ScaleWeight.Find(x => x.Value == model.MeasurementScaleLKDId.ToString()).Selected = true;
            }
            else
            {
                model.MeasurementScale.ScaleOther.Find(x => x.Value == model.MeasurementScaleLKDId.ToString()).Selected = true;
            }


            var result = new UserTrackingDetailTabViewModel()
            {
                User               = user,
                BodyPart           = model.BodyPart,
                MeasurementScale   = model.MeasurementScale,
                Chart              = GetChart(userTrackingDtoList, model),
                UserTrackingDetail = userTrackingDtoList.Select(p => new UserTrackingDetailVModel()
                {
                    Status                = p.Status,
                    UserTrackingDate      = p.UserTrackingDate,
                    BodyPartValueAndScale = GetBodyPartValueByEnum(p, model.BodyPart),
                    BodyPartProgress      = ""
                }).ToList(),
            };

            if (result.Chart != null)
            {
                result.Chart.HtmlControlId = "divProfileChartId";
            }
            return(View(result));
        }
        private ChartJsVModel GetChart(IEnumerable <UserTrackingDto> userTrackingList, UserTrackingFilter filter)
        {
            var model = new UserTrackingChartViewModel()
            {
                BodyPart              = filter.BodyPart,
                UserTrackingBodyPart  = filter.BodyPart,
                MeasurementScaleLKDId = filter.MeasurementScaleLKDId,
                ChartType             = filter.ChartType
            };

            return(_chartHelper.LoadChart(userTrackingList, model));
        }
Exemple #4
0
 public PartialViewResult LoadUserTrackingChartPartialView(UserTrackingFilter searchModel)
 {
     searchModel.MeasurementScale = new Scale(_lookupAppService);
     return(PartialView("_UserTrackingDashboardSection", searchModel));
 }