//
// 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();
}
}