Inheritance: UserBaseInsulinCalcProfileModel
Esempio n. 1
0
        public UserBaseInsulinCalcProfileModel ToUserBaseInsulinCalcProfileModel(UserBaseInsulinCalcProfile baseProfile)
        {
            UserBaseInsulinCalcProfileModel returnProfile = null;
            if (baseProfile != null)
            {
                if(baseProfile is PumpInsulinProfile)
                {
                    returnProfile = new PumpInsulinProfileModel()
                    {
                        PumpType = (baseProfile as PumpInsulinProfile).PumpType
                    };
                }
                else if(baseProfile is RapidInsulinProfile)
                {
                    returnProfile = new RapidInsulinProfileModel()
                    {
                        BasalInsulinAmount = (baseProfile as RapidInsulinProfile).BasalInsulinAmount
                    };
                }

                returnProfile.BirthDate = baseProfile.BirthDate;
                returnProfile.DosageUnits = baseProfile.DosageUnits;
                returnProfile.InsulinCarbohydrateRatio = baseProfile.InsulinCarbohydrateRatio;
                returnProfile.MaxSugarRange = baseProfile.MaxSugarRange;
                returnProfile.MinSugarRange = baseProfile.MinSugarRange;
                returnProfile.Sex = baseProfile.Sex;
                returnProfile.UnitReductionValue = baseProfile.UnitReductionValue;
                returnProfile.UnitReductionUnits = baseProfile.UnitReductionUnits;
                returnProfile.Weight = baseProfile.Weight;
            }
            return returnProfile;
        }
Esempio n. 2
0
        //
        // GET: /User/Create
        public ActionResult Edit(string userName)
        {
            try
            {
                UserProfileModel userProfile = null;
                if (string.IsNullOrEmpty(userName))
                {
                    ViewBag.Massage = "User Name is null or empty";
                    return RedirectToAction("FindUserData");
                }
                else
                {
                    var userProfielBase = UserProfileFacade.GetUserProfile(userName);
                    if (UserProfileFacade.CheckIfJustCreatedProfile(userProfielBase))
                    {
                        ViewBag.Massage = "User not exist.";
                        return RedirectToAction("FindUserData", new { userName = userName });
                    }
                    else
                    {
                        var converter = new ToViewModel();
                        userProfile = converter.ToUserProfileModel(userProfielBase);
                    }

                    if (userProfile.InsulinCalcProfile == null)
                    {
                        UserBaseInsulinCalcProfileModel userInsulineProfile = new PumpInsulinProfileModel();
                        userProfile.InsulinCalcProfile = userInsulineProfile;
                    }
                }

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

                return View(userProfile);
            }
            catch (Exception e)
            {
                log.ErrorFormat("[Edit] Error: Exception={0}.", e.Message);
                return View();
            }
        }
Esempio n. 3
0
        public void JsonConvertTest_ShouldConvertEnumToStrings()
        {
            UserBaseInsulinCalcProfileModel userInsulineProfile = new PumpInsulinProfileModel()
            {
                BirthDate = DateTime.UtcNow,
                MinSugarRange = 110,
                MaxSugarRange = 130,
                Sex = Sex.Male,
                UnitReductionValue = 1.2,
                InsulinCarbohydrateRatio = 2,
                Weight = 90,
                PumpType = PumpType.Medtronic530GWithEnlite,
                UnitReductionUnits = UnitReductionUnits.mmolL,
                DosageUnits = DosageUnits.mg
            };

            var result = JsonConvert.SerializeObject(userInsulineProfile, Formatting.Indented, new StringEnumConverter());

            // Assert
            //Assert.IsInstanceOfType(result, typeof(JsonResult));
            Assert.IsNotNull(result.IndexOf("Medtronic530GWithEnlite") > 0 );
            Assert.IsNotNull(result.IndexOf("mmolL") > 0);
            Assert.IsNotNull(result.IndexOf("mg") > 0);
        }
Esempio n. 4
0
        public string GetUserProfile(string userName)
        {
            try
            {
                UserProfileModel userProfile = null;
                if (string.IsNullOrEmpty(userName))
                {
                    ViewBag.Massage = "User Name is null or empty";
                }
                else
                {
                    var userProfielBase = UserProfileFacade.GetUserProfile(userName);
                    if (UserProfileFacade.CheckIfJustCreatedProfile(userProfielBase))
                    {
                        ViewBag.Massage = "User not exist.";
                    }
                    else
                    {
                        var converter = new ToViewModel();
                        userProfile = converter.ToUserProfileModel(userProfielBase);
                    }

                    if (userProfile.InsulinCalcProfile == null)
                    {
                        UserBaseInsulinCalcProfileModel userInsulineProfile = new PumpInsulinProfileModel();
                        //{
                        //    BirthDate = DateTime.UtcNow,
                        //    MinSugarRange = 110,
                        //    MaxSugarRange = 130,
                        //    Sex = Sex.Male,
                        //    UnitReductionValue = 1.2,
                        //    InsulinCarbohydrateRatio = 2,
                        //    Weight = 90
                        //};

                        //UserBaseInsulinCalcProfileModel userInsulineProfile = new RapidInsulinProfileModel()
                        //{
                        //    BirthDate = DateTime.Parse("25/05/1984"),
                        //    MinSugarRange = 110,
                        //    MaxSugarRange = 130,
                        //    Sex = Sex.Male,
                        //    UnitReductionValue = 1.2,
                        //    InsulinCarbohydrateRatio = 2,
                        //    Weight = 90,
                        //    BasalInsulinAmount = 3.4
                        //};
                        userProfile.InsulinCalcProfile = userInsulineProfile;
                    }
                }
                //var jsonResult = Json(userProfile, JsonRequestBehavior.AllowGet);
                //return jsonResult;
                var jsonResult = JsonConvert.SerializeObject(userProfile, Formatting.Indented, new StringEnumConverter());
                return jsonResult;
            }
            catch (Exception ex)
            {
                log.ErrorFormat("[GetUserProfile] exception={0}.", ex);
                //return Json(null, JsonRequestBehavior.AllowGet);
                return null;
                //throw;
            }
        }
Esempio n. 5
0
        public ActionResult InsulinCalcProfileEdit(string pumpUsage = null)
        {
            UserBaseInsulinCalcProfileModel insulinCalcProfile = UserProfileFacade.GetUserInsulinCalcProfileModel();
            if (insulinCalcProfile == null)
            {
                return RedirectToAction("InsulinCalcProfileCreate");
            }
            if (pumpUsage == null)
            {
                pumpUsage = (insulinCalcProfile is PumpInsulinProfileModel) ? "yes" : "no";
            }
            else
            {
                if (pumpUsage == "yes")
                {
                    if (insulinCalcProfile is RapidInsulinProfileModel)
                    {
                        insulinCalcProfile = new PumpInsulinProfileModel(insulinCalcProfile);
                    }
                }
                else
                {
                    if (pumpUsage == "no")
                    {
                        if (insulinCalcProfile is PumpInsulinProfileModel)
                        {
                            insulinCalcProfile = new RapidInsulinProfileModel(insulinCalcProfile);
                        }
                    }
                }
            }
            ViewBag.pumpUsage = pumpUsage;

            ViewData["reductionUnits"] = DropDownListForHelper.GetSelectListForEnumType<UnitReductionUnits>(UnitReductionUnits.mmolL);
            ViewData["dosageUnits"] = DropDownListForHelper.GetSelectListForEnumType<DosageUnits>(DosageUnits.mg);
            ViewData["pumps"] = DropDownListForHelper.GetSelectListForEnumType<PumpType>(PumpType.RocheAccuChekCombo);
            ViewData["sexes"] = DropDownListForHelper.GetSelectListForEnumType<Sex>(Sex.Male);

            return View(insulinCalcProfile);
        }
Esempio n. 6
0
        public ActionResult InsulinCalcProfileCreate(string pumpUsage = "no")
        {
            log.InfoFormat("[InsulinCalcProfileCreate].");
            UserBaseInsulinCalcProfileModel userInsulineProfile = null;
            if (pumpUsage == "yes")
            {
                userInsulineProfile = new PumpInsulinProfileModel();
                ViewBag.pumpUsage = pumpUsage;
            }
            else
            {
                if (pumpUsage == "no")
                {
                    userInsulineProfile = new RapidInsulinProfileModel();
                    ViewBag.pumpUsage = pumpUsage;
                }
            }

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

            return View(userInsulineProfile);
        }