Beispiel #1
0
        /// <summary>
        /// Loads the drop downs.
        /// </summary>
        private void LoadDropDowns()
        {
            var projectQry = new ResidencyService <Project>().Queryable();

            int competencyPersonId            = hfCompetencyPersonId.ValueAsInt();
            CompetencyPerson competencyPerson = new ResidencyService <CompetencyPerson>().Get(competencyPersonId);

            projectQry = projectQry.Where(a => a.CompetencyId == competencyPerson.CompetencyId);

            // list
            List <int> assignedProjectIds = new ResidencyService <CompetencyPersonProject>().Queryable()
                                            .Where(a => a.CompetencyPersonId.Equals(competencyPersonId))
                                            .Select(a => a.ProjectId).ToList();

            var list = projectQry.Where(a => !assignedProjectIds.Contains(a.Id)).OrderBy(a => a.Name).ToList();

            ddlProject.DataSource = list;
            ddlProject.DataBind();

            bool addMode = hfCompetencyPersonProjectId.ValueAsInt() == 0;

            if (addMode)
            {
                // if Adding a project, warn if there are no Projects left to add
                pnlEditProject.Visible            = list.Any();
                nbAllProjectsAlreadyAdded.Visible = !list.Any();
                btnSave.Visible = list.Any();
            }
            else
            {
                pnlEditProject.Visible            = true;
                nbAllProjectsAlreadyAdded.Visible = false;
                btnSave.Visible = true;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Handles the SelectedIndexChanged event of the ddlTrack control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void ddlTrack_SelectedIndexChanged(object sender, EventArgs e)
        {
            int trackId       = ddlTrack.SelectedValueAsInt() ?? 0;
            var competencyQry = new ResidencyService <Competency>().Queryable().Where(a => a.TrackId == trackId);

            // list
            int        personId = hfPersonId.ValueAsInt();
            List <int> assignedCompetencyIds = new ResidencyService <CompetencyPerson>().Queryable().Where(a => a.PersonId.Equals(personId)).Select(a => a.CompetencyId).ToList();

            var competencyNotYetAssignedList = competencyQry.Where(a => !assignedCompetencyIds.Contains(a.Id)).OrderBy(a => a.Name).ToList();

            ddlCompetency.Visible = competencyNotYetAssignedList.Any();
            nbAllCompetenciesAlreadyAdded.Visible = !competencyNotYetAssignedList.Any();
            btnSave.Visible = competencyNotYetAssignedList.Any();

            competencyNotYetAssignedList.Insert(0, new Competency {
                Id = Rock.Constants.All.Id, Name = Rock.Constants.All.Text
            });

            ddlCompetency.DataSource = competencyNotYetAssignedList;
            ddlCompetency.DataBind();
        }
Beispiel #3
0
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="projectPointOfAssessmentId">The project point of assessment id.</param>
        /// <param name="competencyPersonProjectAssessmentId">The competency person project assessment id.</param>
        public void ShowDetail(int projectPointOfAssessmentId, int competencyPersonProjectAssessmentId)
        {
            pnlDetails.Visible = true;

            var qry = new ResidencyService <CompetencyPersonProjectAssessmentPointOfAssessment>().Queryable();
            CompetencyPersonProjectAssessmentPointOfAssessment competencyPersonProjectAssessmentPointOfAssessment = null;

            competencyPersonProjectAssessmentPointOfAssessment = qry
                                                                 .Where(a => a.ProjectPointOfAssessmentId.Equals(projectPointOfAssessmentId) && a.CompetencyPersonProjectAssessmentId.Equals(competencyPersonProjectAssessmentId)).FirstOrDefault();

            if (competencyPersonProjectAssessmentPointOfAssessment == null)
            {
                competencyPersonProjectAssessmentPointOfAssessment = new CompetencyPersonProjectAssessmentPointOfAssessment {
                    Id = 0
                };
                competencyPersonProjectAssessmentPointOfAssessment.ProjectPointOfAssessmentId = projectPointOfAssessmentId;
                competencyPersonProjectAssessmentPointOfAssessment.ProjectPointOfAssessment
                    = new ResidencyService <ProjectPointOfAssessment>().Get(projectPointOfAssessmentId);
                competencyPersonProjectAssessmentPointOfAssessment.CompetencyPersonProjectAssessmentId = competencyPersonProjectAssessmentId;
                competencyPersonProjectAssessmentPointOfAssessment.CompetencyPersonProjectAssessment
                    = new ResidencyService <CompetencyPersonProjectAssessment>().Get(competencyPersonProjectAssessmentId);
            }

            hfProjectPointOfAssessmentId.Value          = competencyPersonProjectAssessmentPointOfAssessment.ProjectPointOfAssessmentId.ToString();
            hfCompetencyPersonProjectAssessmentId.Value = competencyPersonProjectAssessmentPointOfAssessment.CompetencyPersonProjectAssessmentId.ToString();

            // render UI based on Authorized and IsSystem
            bool readOnly = false;

            nbEditModeMessage.Text = string.Empty;
            if (!IsUserAuthorized("Edit"))
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed("Project Assessment- Point of Assessment");
            }

            if (competencyPersonProjectAssessmentPointOfAssessment.Id > 0)
            {
                lActionTitle.Text = ActionTitle.Edit("Project Assessment- Point of Assessment");
            }
            else
            {
                lActionTitle.Text = ActionTitle.Add("Project Assessment- Point of Assessment");
            }

            var personProject     = competencyPersonProjectAssessmentPointOfAssessment.CompetencyPersonProjectAssessment.CompetencyPersonProject;
            var projectAssessment = competencyPersonProjectAssessmentPointOfAssessment.CompetencyPersonProjectAssessment;

            lblMainDetails.Text = new DescriptionList()
                                  .Add("Resident", personProject.CompetencyPerson.Person)
                                  .Add("Project", string.Format("{0} - {1}", personProject.Project.Name, personProject.Project.Description))
                                  .Add("Competency", personProject.CompetencyPerson.Competency.Name)
                                  .StartSecondColumn()
                                  .Add("Assessment #", competencyPersonProjectAssessmentPointOfAssessment.ProjectPointOfAssessment.AssessmentOrder)
                                  .Add("Assessment Text", competencyPersonProjectAssessmentPointOfAssessment.ProjectPointOfAssessment.AssessmentText)
                                  .Add("Assessor", projectAssessment.AssessorPerson)
                                  .Html;

            tbRating.Text      = competencyPersonProjectAssessmentPointOfAssessment.Rating.ToString();
            tbRatingNotes.Text = competencyPersonProjectAssessmentPointOfAssessment.RatingNotes;

            tbRating.ReadOnly      = readOnly;
            tbRatingNotes.ReadOnly = readOnly;

            btnCancel.Visible = !readOnly;
            btnSave.Text      = readOnly ? "Close" : "Save";
        }
Beispiel #4
0
        /// <summary>
        /// Handles the Click event of the btnSave control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            ResidencyService <CompetencyPerson>        competencyPersonService        = new ResidencyService <CompetencyPerson>();
            ResidencyService <Competency>              competencyService              = new ResidencyService <Competency>();
            ResidencyService <CompetencyPersonProject> competencyPersonProjectService = new ResidencyService <CompetencyPersonProject>();

            int competencyPersonId = int.Parse(hfCompetencyPersonId.Value);
            int trackId            = ddlTrack.SelectedValueAsInt() ?? 0;
            int personId           = hfPersonId.ValueAsInt();

            if (competencyPersonId == 0)
            {
                int        selectedId = ddlCompetency.SelectedValueAsInt() ?? 0;
                List <int> competencyToAssignIdList = null;

                if (selectedId == Rock.Constants.All.Id)
                {
                    // add all the Competencies for this Track that they don't have yet
                    var competencyQry = new ResidencyService <Competency>().Queryable().Where(a => a.TrackId == trackId);

                    // list
                    List <int> assignedCompetencyIds = new ResidencyService <CompetencyPerson>().Queryable().Where(a => a.PersonId.Equals(personId)).Select(a => a.CompetencyId).ToList();

                    competencyToAssignIdList = competencyQry.Where(a => !assignedCompetencyIds.Contains(a.Id)).OrderBy(a => a.Name).Select(a => a.Id).ToList();
                }
                else
                {
                    // just add the selected Competency
                    competencyToAssignIdList = new List <int>();
                    competencyToAssignIdList.Add(selectedId);
                }

                RockTransactionScope.WrapTransaction(() =>
                {
                    foreach (var competencyId in competencyToAssignIdList)
                    {
                        CompetencyPerson competencyPerson = new CompetencyPerson();
                        competencyPersonService.Add(competencyPerson, CurrentPersonId);
                        competencyPerson.PersonId     = hfPersonId.ValueAsInt();
                        competencyPerson.CompetencyId = competencyId;
                        competencyPersonService.Save(competencyPerson, CurrentPersonId);

                        Competency competency = competencyService.Get(competencyId);
                        foreach (var project in competency.Projects)
                        {
                            // add all the projects associated with the competency
                            CompetencyPersonProject competencyPersonProject = new CompetencyPersonProject
                            {
                                CompetencyPersonId = competencyPerson.Id,
                                ProjectId          = project.Id,
                                MinAssessmentCount = null
                            };

                            competencyPersonProjectService.Add(competencyPersonProject, CurrentPersonId);
                            competencyPersonProjectService.Save(competencyPersonProject, CurrentPersonId);
                        }
                    }
                });
            }
            else
            {
                // shouldn't happen, they can only Add
            }

            var qryParams = new Dictionary <string, string>();

            qryParams["personId"] = personId.ToString();
            NavigateToParentPage(qryParams);
        }