Пример #1
0
 /*
  * CREATED:     A. Valberg		MAR 16 2018
  *
  * Page_Load()
  * This method runs when the page loads. It also checks user authorization levels before displaying data.
  *
  * PARAMETERS:
  * object sender - object on the page that is being targeted
  * EventArgs e - event that has triggered the method
  *
  * RETURNS:
  * void
  *
  * ODEV METHOD CALLS:
  * MessageUserControl.ShowErrorMessage()
  * CareSiteController.GetCareSiteByCareSiteID()
  * UnitController.GetCareSiteUnits()
  * GetActiveCareSites()
  * RespondentTypeController.GetAllRespondentTypes()
  * GenderController.GetAllGenders()
  * AgeController.GetAllAges()
  * CareSiteController.GetCareSites()
  */
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (User.IsInRole(AuthorizationLevelRoles.User))
         {
             ApplicationUser user       = userManager.FindById(User.Identity.GetUserId());
             int             careSiteID = user.caresiteid == null ? 0 : (int)user.caresiteid;
             if (careSiteID == 0)
             {
                 MessageUserControl.ShowErrorMessage("Your account has no assigned care site. Please contact your administrator to be assigned a care site.");
             }
             else
             {
                 CareSiteDDL.Items.Clear();
                 CareSiteDDL.Items.Add(new ListItem(careSiteController.GetCareSiteByCareSiteID(careSiteID).caresitename, careSiteID.ToString()));
                 UnitRepeater.DataSource = unitController.GetCareSiteUnits(careSiteID);
                 UnitRepeater.DataBind();
                 RespondentTypeRepeater.DataSource = respondentTypeController.GetAllRespondentTypes();
                 RespondentTypeRepeater.DataBind();
                 GenderRepeater.DataSource = genderController.GetAllGenders();
                 GenderRepeater.DataBind();
                 AgeGroupRepeater.DataSource = ageController.GetAllAges();
                 AgeGroupRepeater.DataBind();
             }
         }
         else
         {
             CareSiteDDL.DataSource = careSiteController.GetCareSites();
             CareSiteDDL.DataBind();
             unitsdiv.Attributes.Add("style", "display:none");
             RespondentTypeRepeater.DataSource = respondentTypeController.GetAllRespondentTypes();
             RespondentTypeRepeater.DataBind();
             GenderRepeater.DataSource = genderController.GetAllGenders();
             GenderRepeater.DataBind();
             AgeGroupRepeater.DataSource = ageController.GetAllAges();
             AgeGroupRepeater.DataBind();
         }
     }
 }