public UserBaseInsulinCalcProfile ToInsulinProfileBaseModel(UserBaseInsulinCalcProfileModel insulinProfile)
        {
            UserBaseInsulinCalcProfile returnValue = null;
            if(insulinProfile is PumpInsulinProfileModel)
            {
                returnValue = new PumpInsulinProfile()
                {
                    PumpType = ((PumpInsulinProfileModel)insulinProfile).PumpType
                };
            }
            else if(insulinProfile is RapidInsulinProfileModel)
            {
                returnValue = new RapidInsulinProfile()
                {
                    BasalInsulinAmount = ((RapidInsulinProfileModel)insulinProfile).BasalInsulinAmount
                };
            }
            //returnValue.BirthDate = insulinProfile.BirthDate;
            returnValue.DosageUnits = insulinProfile.DosageUnits;
            returnValue.InsulinCarbohydrateRatio = insulinProfile.InsulinCarbohydrateRatio;
            returnValue.MaxSugarRange = insulinProfile.MaxSugarRange;
            returnValue.MinSugarRange = insulinProfile.MinSugarRange;
            returnValue.Sex = insulinProfile.Sex;
            returnValue.UnitReductionValue = insulinProfile.UnitReductionValue;
            returnValue.UnitReductionUnits = insulinProfile.UnitReductionUnits;
            returnValue.Weight = insulinProfile.Weight;

            return returnValue;
        }
 public PumpInsulinProfileModel(UserBaseInsulinCalcProfileModel insulineProfile)
 {
     BirthDate = insulineProfile.BirthDate;
     DosageUnits = insulineProfile.DosageUnits;
     InsulinCarbohydrateRatio = insulineProfile.InsulinCarbohydrateRatio;
     MaxSugarRange = insulineProfile.MaxSugarRange;
     MinSugarRange = insulineProfile.MinSugarRange;
     Sex = insulineProfile.Sex;
     UnitReductionValue = insulineProfile.UnitReductionValue;
     UnitReductionUnits = insulineProfile.UnitReductionUnits;
     Weight = insulineProfile.Weight;
     if (insulineProfile is PumpInsulinProfileModel)
     {
         PumpType = (insulineProfile as PumpInsulinProfileModel).PumpType;
     }
 }
 public RapidInsulinProfileModel(UserBaseInsulinCalcProfileModel insulineProfile)
 {
     BirthDate = insulineProfile.BirthDate;
     DosageUnits = insulineProfile.DosageUnits;
     InsulinCarbohydrateRatio = insulineProfile.InsulinCarbohydrateRatio;
     MaxSugarRange = insulineProfile.MaxSugarRange;
     MinSugarRange = insulineProfile.MinSugarRange;
     Sex = insulineProfile.Sex;
     UnitReductionValue = insulineProfile.UnitReductionValue;
     UnitReductionUnits = insulineProfile.UnitReductionUnits;
     Weight = insulineProfile.Weight;
     if (insulineProfile is RapidInsulinProfileModel)
     {
         BasalInsulinAmount = (insulineProfile as RapidInsulinProfileModel).BasalInsulinAmount;
     }
 }
Example #4
0
        public ActionResult InsulinCalcProfileEditConfirmed(UserBaseInsulinCalcProfileModel insulinProfileModel)
        {
            try
            {
                log.InfoFormat("[InsulinCalcProfileEditConfirmed].");
                ModelState.Remove("BasalInsulinAmount");
                ModelState.Remove("PumpType");
                ModelState.Remove("Weight");
                if (ModelState.IsValid)
                {
                    ViewBag.Message = "Model valid";
                    ProfileBase profileBase = UserProfileFacade.GetUserProfile();
                    if (insulinProfileModel != null)
                    {
                        profileBase.SetUserInsulinCalcProfile(insulinProfileModel);
                    }
                }
                else
                {
                    ViewBag.Message = "Model not valid.";
                }

                //Temporary here
                ViewData["reductionUnits"] = DropDownListForHelper.GetSelectListForEnumType<UnitReductionUnits>();
                ViewData["dosageUnits"] = DropDownListForHelper.GetSelectListForEnumType<DosageUnits>();
                ViewData["pumps"] = DropDownListForHelper.GetSelectListForEnumType<PumpType>();
                ViewData["sexes"] = DropDownListForHelper.GetSelectListForEnumType<Sex>();

                if (insulinProfileModel is PumpInsulinProfileModel)
                {
                    ViewBag.pumpUsage = "yes";
                }
                else
                {
                    if (insulinProfileModel is RapidInsulinProfileModel)
                    {
                        ViewBag.pumpUsage = "no";
                    }

                }

                return View(insulinProfileModel);
            }
            catch (Exception e)
            {
                log.InfoFormat("[InsulinCalcProfileEditConfirmed]. Exception={0}.", e.Message);
                ViewBag.Message = "Model not valid. " + e.Message;
                return View(insulinProfileModel);
            }
        }
Example #5
0
 public static void SetUserInsulinCalcProfile(this ProfileBase userProfile, UserBaseInsulinCalcProfileModel userInsulineProfile)
 {
     if (userInsulineProfile != null)
     {
         var userData = userProfile.GetUserData();
         var converter = new ToBaseModelConverter();
         userData.BaseInsulinCalcProfile = converter.ToInsulinProfileBaseModel(userInsulineProfile);
         userProfile.SetUserData(userData);
         userProfile.Save();
     }
 }