/// <summary> /// Handles the Delete event of the gList control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RowEventArgs"/> instance containing the event data.</param> protected void gList_Delete(object sender, RowEventArgs e) { RockTransactionScope.WrapTransaction(() => { var projectPointOfAssessmentService = new ResidencyService <ProjectPointOfAssessment>(); ProjectPointOfAssessment projectPointOfAssessment = projectPointOfAssessmentService.Get((int)e.RowKeyValue); if (projectPointOfAssessment != null) { string errorMessage; if (!projectPointOfAssessmentService.CanDelete(projectPointOfAssessment, out errorMessage)) { mdGridWarning.Show(errorMessage, ModalAlertType.Information); return; } projectPointOfAssessmentService.Delete(projectPointOfAssessment, CurrentPersonId); projectPointOfAssessmentService.Save(projectPointOfAssessment, CurrentPersonId); int iProjectId = hfProjectId.ValueAsInt(); // after an item is deleted, we need to renumber all the items List <ProjectPointOfAssessment> items = projectPointOfAssessmentService.Queryable().Where(a => a.ProjectId == iProjectId).OrderBy(a => a.AssessmentOrder).ToList(); UpdateItemOrders(projectPointOfAssessmentService, items); } }); BindGrid(); }
/// <summary> /// Handles the Click event of the btnEdit 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 btnEdit_Click(object sender, EventArgs e) { ResidencyService <Project> service = new ResidencyService <Project>(); Project item = service.Get(hfProjectId.ValueAsInt()); ShowEditDetails(item); }
/// <summary> /// Handles the Click event of the btnEdit 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 btnEdit_Click(object sender, EventArgs e) { ResidencyService <Competency> service = new ResidencyService <Competency>(); Competency item = service.Get(hfCompetencyId.ValueAsInt()); ShowEditDetails(item); }
/// <summary> /// Handles the Click event of the btnEdit 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 btnEdit_Click(object sender, EventArgs e) { ResidencyService <Track> service = new ResidencyService <Track>(); Track item = service.Get(hfTrackId.ValueAsInt()); ShowEditDetails(item); }
/// <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 <CompetencyPersonProjectAssessment> service = new ResidencyService <CompetencyPersonProjectAssessment>(); int competencyPersonProjectAssessmentId = hfCompetencyPersonProjectAssessmentId.ValueAsInt(); CompetencyPersonProjectAssessment competencyPersonProjectAssessment = service.Get(competencyPersonProjectAssessmentId); competencyPersonProjectAssessment.ResidentComments = tbResidentComments.Text; if (!competencyPersonProjectAssessment.IsValid) { // Controls will render the error messages return; } RockTransactionScope.WrapTransaction(() => { service.Save(competencyPersonProjectAssessment, CurrentPersonId); }); var qryParams = new Dictionary <string, string>(); qryParams["competencyPersonProjectAssessmentId"] = competencyPersonProjectAssessment.Id.ToString(); NavigateToPage(this.CurrentPage.Guid, qryParams); }
/// <summary> /// Handles the Click event of the btnEdit 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 btnEdit_Click(object sender, EventArgs e) { ResidencyService <CompetencyPersonProjectAssessment> service = new ResidencyService <CompetencyPersonProjectAssessment>(); CompetencyPersonProjectAssessment item = service.Get(hfCompetencyPersonProjectAssessmentId.ValueAsInt()); ShowEditDetails(item); }
/// <summary> /// Handles the Click event of the btnCancel 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 btnCancel_Click( object sender, EventArgs e ) { SetEditMode( false ); if ( hfCompetencyPersonProjectAssessmentId.ValueAsInt().Equals( 0 ) ) { // Cancelling on Add. Return to Grid // if this page was called from the Project Detail page, return to that string competencyPersonProjectId = PageParameter( "competencyPersonProjectId" ); if ( !string.IsNullOrWhiteSpace( competencyPersonProjectId ) ) { Dictionary<string, string> qryString = new Dictionary<string, string>(); qryString["competencyPersonProjectId"] = competencyPersonProjectId; NavigateToParentPage( qryString ); } else { NavigateToParentPage(); } } else { // Cancelling on Edit. Return to Details ResidencyService<CompetencyPersonProjectAssessment> service = new ResidencyService<CompetencyPersonProjectAssessment>(); CompetencyPersonProjectAssessment item = service.Get( hfCompetencyPersonProjectAssessmentId.ValueAsInt() ); ShowReadonlyDetails( item ); } }
/// <summary> /// Handles the Click event of the btnCancel 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 btnCancel_Click(object sender, EventArgs e) { SetEditMode(false); // Cancelling on Edit. Return to Details ResidencyService <CompetencyPersonProjectAssessment> service = new ResidencyService <CompetencyPersonProjectAssessment>(); CompetencyPersonProjectAssessment item = service.Get(hfCompetencyPersonProjectAssessmentId.ValueAsInt()); ShowReadonlyDetails(item); }
/// <summary> /// Binds the grid. /// </summary> private void BindGrid() { var competencyPersonProjectService = new ResidencyService <CompetencyPersonProject>(); int competencyPersonProjectId = hfCompetencyPersonProjectId.ValueAsInt(); CompetencyPersonProject competencyPersonProject = competencyPersonProjectService.Get(competencyPersonProjectId); if (competencyPersonProject.CompetencyPerson.PersonId != CurrentPersonId) { // somebody besides the Resident is logged in Dictionary <string, string> qryString = new Dictionary <string, string>(); qryString["competencyPersonId"] = competencyPersonProject.CompetencyPersonId.ToString(); NavigateToParentPage(qryString); return; } var rawList = competencyPersonProject.Project.ProjectPointOfAssessments .OrderBy(s => s.AssessmentOrder).ToList(); foreach (var item in rawList) { if (item.PointOfAssessmentTypeValue != null) { item.PointOfAssessmentTypeValue.LoadAttributes(); } } var selectList = rawList.Select(a => new { a.Id, ProjectPointOfAssessmentColor = a.PointOfAssessmentTypeValue != null ? a.PointOfAssessmentTypeValue.GetAttributeValue("Color") : string.Empty, a.PointOfAssessmentTypeValue, a.AssessmentOrder, a.AssessmentText }).ToList(); if (competencyPersonProject != null) { gList.DataSource = selectList; gList.DataBind(); } else { NavigateToParentPage(); return; } }
/// <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) { CompetencyPersonProject competencyPersonProject; ResidencyService <CompetencyPersonProject> competencyPersonProjectService = new ResidencyService <CompetencyPersonProject>(); int competencyPersonProjectId = int.Parse(hfCompetencyPersonProjectId.Value); if (competencyPersonProjectId == 0) { competencyPersonProject = new CompetencyPersonProject(); competencyPersonProjectService.Add(competencyPersonProject, CurrentPersonId); // these inputs are only editable on Add competencyPersonProject.ProjectId = ddlProject.SelectedValueAsInt() ?? 0; competencyPersonProject.CompetencyPersonId = hfCompetencyPersonId.ValueAsInt(); } else { competencyPersonProject = competencyPersonProjectService.Get(competencyPersonProjectId); } if (!string.IsNullOrWhiteSpace(tbMinAssessmentCountOverride.Text)) { competencyPersonProject.MinAssessmentCount = tbMinAssessmentCountOverride.Text.AsInteger(); } else { competencyPersonProject.MinAssessmentCount = null; } if (!competencyPersonProject.IsValid) { // Controls will render the error messages return; } RockTransactionScope.WrapTransaction(() => { competencyPersonProjectService.Save(competencyPersonProject, CurrentPersonId); }); var qryParams = new Dictionary <string, string>(); qryParams["competencyPersonProjectId"] = competencyPersonProject.Id.ToString(); NavigateToPage(this.CurrentPage.Guid, qryParams); }
/// <summary> /// Handles the Click event of the btnCancel 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 btnCancel_Click(object sender, EventArgs e) { SetEditMode(false); if (hfPeriodId.ValueAsInt().Equals(0)) { // Cancelling on Add. Return to Grid NavigateToParentPage(); } else { // Cancelling on Edit. Return to Details ResidencyService <Period> service = new ResidencyService <Period>(); Period item = service.Get(hfPeriodId.ValueAsInt()); ShowReadonlyDetails(item); } }
/// <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) { if (dpStartDate.SelectedDate > dpEndDate.SelectedDate) { dpStartDate.ShowErrorMessage(WarningMessage.DateRangeEndDateBeforeStartDate()); return; } Period period; ResidencyService <Period> periodService = new ResidencyService <Period>(); int periodId = int.Parse(hfPeriodId.Value); if (periodId == 0) { period = new Period(); periodService.Add(period, CurrentPersonId); } else { period = periodService.Get(periodId); } period.Name = tbName.Text; period.Description = tbDescription.Text; period.StartDate = dpStartDate.SelectedDate; period.EndDate = dpEndDate.SelectedDate; if (!period.IsValid) { // Controls will render the error messages return; } RockTransactionScope.WrapTransaction(() => { periodService.Save(period, CurrentPersonId); }); var qryParams = new Dictionary <string, string>(); qryParams["periodId"] = period.Id.ToString(); NavigateToPage(this.CurrentPage.Guid, qryParams); }
/// <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) { Track track; ResidencyService <Track> trackService = new ResidencyService <Track>(); int trackId = hfTrackId.ValueAsInt(); int periodId = hfPeriodId.ValueAsInt(); if (trackId == 0) { track = new Track(); trackService.Add(track, CurrentPersonId); int maxDisplayOrder = trackService.Queryable() .Where(a => a.PeriodId.Equals(periodId)) .Select(a => a.DisplayOrder).DefaultIfEmpty(0).Max(); track.DisplayOrder = maxDisplayOrder + 1; } else { track = trackService.Get(trackId); } track.Name = tbName.Text; track.Description = tbDescription.Text; track.PeriodId = periodId; if (!track.IsValid) { // Controls will render the error messages return; } RockTransactionScope.WrapTransaction(() => { trackService.Save(track, CurrentPersonId); }); var qryParams = new Dictionary <string, string>(); qryParams["trackId"] = track.Id.ToString(); NavigateToPage(this.CurrentPage.Guid, qryParams); }
/// <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) { Competency competency; ResidencyService <Competency> competencyService = new ResidencyService <Competency>(); int competencyId = int.Parse(hfCompetencyId.Value); if (competencyId == 0) { competency = new Competency(); competencyService.Add(competency, CurrentPersonId); } else { competency = competencyService.Get(competencyId); } competency.Name = tbName.Text; competency.Description = tbDescription.Text; competency.TrackId = hfTrackId.ValueAsInt(); competency.TeacherOfRecordPersonId = ppTeacherOfRecord.PersonId; competency.FacilitatorPersonId = ppFacilitator.PersonId; competency.Goals = tbGoals.Text; competency.CreditHours = tbCreditHours.Text.AsInteger(false); competency.SupervisionHours = tbSupervisionHours.Text.AsInteger(false); competency.ImplementationHours = tbImplementationHours.Text.AsInteger(false); if (!competency.IsValid) { // Controls will render the error messages return; } RockTransactionScope.WrapTransaction(() => { competencyService.Save(competency, CurrentPersonId); }); var qryParams = new Dictionary <string, string>(); qryParams["competencyId"] = competency.Id.ToString(); NavigateToPage(this.CurrentPage.Guid, qryParams); }
/// <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 ) { CompetencyPersonProjectAssessment competencyPersonProjectAssessment; ResidencyService<CompetencyPersonProjectAssessment> competencyPersonProjectAssessmentService = new ResidencyService<CompetencyPersonProjectAssessment>(); int competencyPersonProjectAssessmentId = int.Parse( hfCompetencyPersonProjectAssessmentId.Value ); if ( competencyPersonProjectAssessmentId == 0 ) { competencyPersonProjectAssessment = new CompetencyPersonProjectAssessment(); competencyPersonProjectAssessmentService.Add( competencyPersonProjectAssessment, CurrentPersonId ); } else { competencyPersonProjectAssessment = competencyPersonProjectAssessmentService.Get( competencyPersonProjectAssessmentId ); } competencyPersonProjectAssessment.CompetencyPersonProjectId = hfCompetencyPersonProjectId.ValueAsInt(); competencyPersonProjectAssessment.AssessorPersonId = ppAssessor.PersonId; competencyPersonProjectAssessment.AssessmentDateTime = dtpAssessmentDateTime.SelectedDateTime; competencyPersonProjectAssessment.RatingNotes = tbRatingNotes.Text; competencyPersonProjectAssessment.ResidentComments = tbResidentComments.Text; if ( !competencyPersonProjectAssessment.IsValid ) { // Controls will render the error messages return; } RockTransactionScope.WrapTransaction( () => { competencyPersonProjectAssessmentService.Save( competencyPersonProjectAssessment, CurrentPersonId ); } ); var qryParams = new Dictionary<string, string>(); qryParams["competencyPersonProjectAssessmentId"] = competencyPersonProjectAssessment.Id.ToString(); NavigateToPage( this.CurrentPage.Guid, qryParams ); }
/// <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) { Project project; ResidencyService <Project> projectService = new ResidencyService <Project>(); int projectId = int.Parse(hfProjectId.Value); if (projectId == 0) { project = new Project(); projectService.Add(project, CurrentPersonId); } else { project = projectService.Get(projectId); } project.Name = tbName.Text; project.Description = tbDescription.Text; project.CompetencyId = hfCompetencyId.ValueAsInt(); project.MinAssessmentCountDefault = tbMinAssessmentCountDefault.Text.AsInteger(false); if (!project.IsValid) { // Controls will render the error messages return; } RockTransactionScope.WrapTransaction(() => { projectService.Save(project, CurrentPersonId); }); var qryParams = new Dictionary <string, string>(); qryParams["projectId"] = project.Id.ToString(); NavigateToPage(this.CurrentPage.Guid, qryParams); }
/// <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) { ProjectPointOfAssessment projectPointOfAssessment; ResidencyService <ProjectPointOfAssessment> projectPointOfAssessmentService = new ResidencyService <ProjectPointOfAssessment>(); int projectPointOfAssessmentId = int.Parse(hfProjectPointOfAssessmentId.Value); if (projectPointOfAssessmentId == 0) { projectPointOfAssessment = new ProjectPointOfAssessment(); projectPointOfAssessment.AssessmentOrder = lblAssessmentOrder.Text.AsInteger().Value; projectPointOfAssessment.ProjectId = hfProjectId.ValueAsInt(); projectPointOfAssessmentService.Add(projectPointOfAssessment, CurrentPersonId); } else { projectPointOfAssessment = projectPointOfAssessmentService.Get(projectPointOfAssessmentId); } projectPointOfAssessment.PointOfAssessmentTypeValueId = ddlPointOfAssessmentTypeValue.SelectedValueAsInt(); projectPointOfAssessment.AssessmentText = tbAssessmentText.Text; if (!projectPointOfAssessment.IsValid) { // Controls will render the error messages return; } RockTransactionScope.WrapTransaction(() => { projectPointOfAssessmentService.Save(projectPointOfAssessment, CurrentPersonId); }); Dictionary <string, string> qryString = new Dictionary <string, string>(); qryString["projectId"] = hfProjectId.Value; NavigateToParentPage(qryString); }
/// <summary> /// Handles the Delete event of the gList control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RowEventArgs"/> instance containing the event data.</param> protected void gList_Delete(object sender, RowEventArgs e) { RockTransactionScope.WrapTransaction(() => { var trackService = new ResidencyService <Track>(); Track track = trackService.Get((int)e.RowKeyValue); if (track != null) { string errorMessage; if (!trackService.CanDelete(track, out errorMessage)) { mdGridWarning.Show(errorMessage, ModalAlertType.Information); return; } trackService.Delete(track, CurrentPersonId); trackService.Save(track, CurrentPersonId); } }); BindGrid(); }
/// <summary> /// Handles the Delete event of the gList control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RowEventArgs"/> instance containing the event data.</param> protected void gList_Delete(object sender, RowEventArgs e) { RockTransactionScope.WrapTransaction(() => { var competencyPersonProjectService = new ResidencyService <CompetencyPersonProject>(); CompetencyPersonProject competencyPersonProject = competencyPersonProjectService.Get((int)e.RowKeyValue); if (competencyPersonProject != null) { string errorMessage; if (!competencyPersonProjectService.CanDelete(competencyPersonProject, out errorMessage)) { mdGridWarning.Show(errorMessage, ModalAlertType.Information); return; } competencyPersonProjectService.Delete(competencyPersonProject, CurrentPersonId); competencyPersonProjectService.Save(competencyPersonProject, CurrentPersonId); } }); BindGrid(); }
/// <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); }
/// <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) { CompetencyPersonProject competencyPersonProject; ResidencyService <CompetencyPersonProject> competencyPersonProjectService = new ResidencyService <CompetencyPersonProject>(); CompetencyPersonProjectAssessment competencyPersonProjectAssessment; ResidencyService <CompetencyPersonProjectAssessment> competencyPersonProjectAssessmentService = new ResidencyService <CompetencyPersonProjectAssessment>(); ResidencyService <CompetencyPersonProjectAssessmentPointOfAssessment> competencyPersonProjectAssessmentPointOfAssessmentService = new ResidencyService <CompetencyPersonProjectAssessmentPointOfAssessment>(); int competencyPersonProjectId = hfCompetencyPersonProjectId.ValueAsInt(); if (competencyPersonProjectId == 0) { competencyPersonProject = new CompetencyPersonProject(); competencyPersonProjectService.Add(competencyPersonProject, CurrentPersonId); } else { competencyPersonProject = competencyPersonProjectService.Get(competencyPersonProjectId); } int competencyPersonProjectAssessmentId = hfCompetencyPersonProjectAssessmentId.ValueAsInt(); if (competencyPersonProjectAssessmentId == 0) { competencyPersonProjectAssessment = new CompetencyPersonProjectAssessment(); competencyPersonProjectAssessmentService.Add(competencyPersonProjectAssessment, CurrentPersonId); } else { competencyPersonProjectAssessment = competencyPersonProjectAssessmentService.Get(competencyPersonProjectAssessmentId); competencyPersonProjectAssessment.CompetencyPersonProjectAssessmentPointOfAssessments = new List <CompetencyPersonProjectAssessmentPointOfAssessment>(); } // set competencyPersonProjectAssessment.CompetencyPersonProjectId after saving competencyPersonProject in case it is new competencyPersonProjectAssessment.AssessmentDateTime = DateTime.Now; competencyPersonProjectAssessment.RatingNotes = tbRatingNotesOverall.Text; competencyPersonProjectAssessment.AssessorPersonId = hfAssessorPersonId.ValueAsInt(); if (!competencyPersonProjectAssessment.IsValid) { // Controls will render the error messages return; } List <CompetencyPersonProjectAssessmentPointOfAssessment> competencyPersonProjectAssessmentPointOfAssessmentList = new List <CompetencyPersonProjectAssessmentPointOfAssessment>(); foreach (RepeaterItem item in rptPointOfAssessment.Items.OfType <RepeaterItem>()) { HiddenField hfProjectPointOfAssessmentId = item.FindControl("hfProjectPointOfAssessmentId") as HiddenField; int projectPointOfAssessmentId = hfProjectPointOfAssessmentId.ValueAsInt(); CompetencyPersonProjectAssessmentPointOfAssessment competencyPersonProjectAssessmentPointOfAssessment = competencyPersonProjectAssessmentPointOfAssessmentService.Queryable() .Where(a => a.ProjectPointOfAssessmentId == projectPointOfAssessmentId) .Where(a => a.CompetencyPersonProjectAssessmentId == competencyPersonProjectAssessmentId).FirstOrDefault(); if (competencyPersonProjectAssessmentPointOfAssessment == null) { competencyPersonProjectAssessmentPointOfAssessment = new CompetencyPersonProjectAssessmentPointOfAssessment(); //// set competencyPersonProjectAssessmentPointOfAssessment.CompetencyPersonProjectAssessmentId = competencyPersonProjectAssessment.Id in save in case it's new competencyPersonProjectAssessmentPointOfAssessment.ProjectPointOfAssessmentId = projectPointOfAssessmentId; } LabeledDropDownList ddlPointOfAssessmentRating = item.FindControl("ddlPointOfAssessmentRating") as LabeledDropDownList; TextBox tbRatingNotesPOA = item.FindControl("tbRatingNotesPOA") as TextBox; competencyPersonProjectAssessmentPointOfAssessment.Rating = ddlPointOfAssessmentRating.SelectedValueAsInt(); competencyPersonProjectAssessmentPointOfAssessment.RatingNotes = tbRatingNotesPOA.Text; competencyPersonProjectAssessmentPointOfAssessmentList.Add(competencyPersonProjectAssessmentPointOfAssessment); } RockTransactionScope.WrapTransaction(() => { competencyPersonProjectService.Save(competencyPersonProject, CurrentPersonId); competencyPersonProjectAssessment.CompetencyPersonProjectId = competencyPersonProject.Id; // set Overall Rating based on average of POA ratings competencyPersonProjectAssessment.OverallRating = (decimal?)competencyPersonProjectAssessmentPointOfAssessmentList.Average(a => a.Rating); competencyPersonProjectAssessmentService.Save(competencyPersonProjectAssessment, CurrentPersonId); foreach (var competencyPersonProjectAssessmentPointOfAssessment in competencyPersonProjectAssessmentPointOfAssessmentList) { competencyPersonProjectAssessmentPointOfAssessment.CompetencyPersonProjectAssessmentId = competencyPersonProjectAssessment.Id; if (competencyPersonProjectAssessmentPointOfAssessment.Id == 0) { competencyPersonProjectAssessmentPointOfAssessmentService.Add(competencyPersonProjectAssessmentPointOfAssessment, CurrentPersonId); } competencyPersonProjectAssessmentPointOfAssessmentService.Save(competencyPersonProjectAssessmentPointOfAssessment, CurrentPersonId); } }); Rock.Model.Page page = null; string personProjectDetailPageGuid = this.GetAttributeValue("PersonProjectDetailPage"); if (!string.IsNullOrWhiteSpace(personProjectDetailPageGuid)) { page = new PageService().Get(new Guid(personProjectDetailPageGuid)); } if (page != null) { Dictionary <string, string> qryString = new Dictionary <string, string>(); qryString["competencyPersonProjectId"] = hfCompetencyPersonProjectId.Value; NavigateToPage(page.Guid, qryString); } else { throw new Exception("PersonProjectDetailPage not configured correctly"); } }
/// <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) { int projectPointOfAssessmentId = hfProjectPointOfAssessmentId.ValueAsInt(); int competencyPersonProjectAssessmentId = hfCompetencyPersonProjectAssessmentId.ValueAsInt(); var competencyPersonProjectAssessmentPointOfAssessmentService = new ResidencyService <CompetencyPersonProjectAssessmentPointOfAssessment>(); CompetencyPersonProjectAssessmentPointOfAssessment competencyPersonProjectAssessmentPointOfAssessment = null; competencyPersonProjectAssessmentPointOfAssessment = competencyPersonProjectAssessmentPointOfAssessmentService.Queryable() .Where(a => a.ProjectPointOfAssessmentId.Equals(projectPointOfAssessmentId) && a.CompetencyPersonProjectAssessmentId.Equals(competencyPersonProjectAssessmentId)) .FirstOrDefault(); if (competencyPersonProjectAssessmentPointOfAssessment == null) { // Create a record to store the rating for this PointOfAssessment if one doesn't already exist competencyPersonProjectAssessmentPointOfAssessment = new CompetencyPersonProjectAssessmentPointOfAssessment { Id = 0 }; competencyPersonProjectAssessmentPointOfAssessment.ProjectPointOfAssessmentId = projectPointOfAssessmentId; competencyPersonProjectAssessmentPointOfAssessment.CompetencyPersonProjectAssessmentId = competencyPersonProjectAssessmentId; competencyPersonProjectAssessmentPointOfAssessmentService.Add(competencyPersonProjectAssessmentPointOfAssessment, CurrentPersonId); } competencyPersonProjectAssessmentPointOfAssessment.Rating = tbRating.Text.AsInteger(); competencyPersonProjectAssessmentPointOfAssessment.RatingNotes = tbRatingNotes.Text; if (!competencyPersonProjectAssessmentPointOfAssessment.IsValid) { // Controls will render the error messages return; } RockTransactionScope.WrapTransaction(() => { competencyPersonProjectAssessmentPointOfAssessmentService.Save(competencyPersonProjectAssessmentPointOfAssessment, CurrentPersonId); // get the CompetencyPersonProjectAssessment using the same dbContext var competencyPersonProjectAssessmentService = new ResidencyService <CompetencyPersonProjectAssessment>(competencyPersonProjectAssessmentPointOfAssessmentService.ResidencyContext); CompetencyPersonProjectAssessment competencyPersonProjectAssessment = competencyPersonProjectAssessmentService.Get(competencyPersonProjectAssessmentId); // set Overall Rating based on average of POA ratings competencyPersonProjectAssessment.OverallRating = (decimal?)competencyPersonProjectAssessment.CompetencyPersonProjectAssessmentPointOfAssessments.Average(a => a.Rating); competencyPersonProjectAssessmentService.Save(competencyPersonProjectAssessment, CurrentPersonId); }); if (competencyPersonProjectAssessmentId != 0) { Dictionary <string, string> qryString = new Dictionary <string, string>(); qryString["competencyPersonProjectAssessmentId"] = competencyPersonProjectAssessmentId.ToString(); NavigateToParentPage(qryString); } else { NavigateToParentPage(); } }
/// <summary> /// Shows the detail /// </summary> /// <param name="itemKey">The item key.</param> /// <param name="itemKeyValue">The item key value.</param> /// <param name="projectId">The residency project id.</param> public void ShowDetail(string itemKey, int itemKeyValue, int?projectId) { // return if unexpected itemKey if (itemKey != "projectPointOfAssessmentId") { return; } pnlDetails.Visible = true; LoadDropDowns(); // Load depending on Add(0) or Edit ProjectPointOfAssessment projectPointOfAssessment = null; var projectPointOfAssessmentService = new ResidencyService <ProjectPointOfAssessment>(); string projectName = new ResidencyService <Project>().Queryable() .Where(a => a.Id.Equals(projectId.Value)) .Select(a => a.Name).FirstOrDefault(); if (!itemKeyValue.Equals(0)) { projectPointOfAssessment = projectPointOfAssessmentService.Get(itemKeyValue); lActionTitle.Text = ActionTitle.Edit("Point of Assessment " + projectPointOfAssessment.AssessmentOrder.ToString()); } else { // don't try add if there wasn't a projectId specified if (projectId != null) { projectPointOfAssessment = new ProjectPointOfAssessment { Id = 0, ProjectId = projectId.Value }; int maxAssessmentOrder = projectPointOfAssessmentService.Queryable() .Where(a => a.ProjectId.Equals(projectPointOfAssessment.ProjectId)) .Select(a => a.AssessmentOrder).DefaultIfEmpty(0).Max(); projectPointOfAssessment.AssessmentOrder = maxAssessmentOrder + 1; lActionTitle.Text = ActionTitle.Add("Point of Assessment " + projectPointOfAssessment.AssessmentOrder.ToString()); } } if (projectPointOfAssessment == null) { return; } hfProjectPointOfAssessmentId.Value = projectPointOfAssessment.Id.ToString(); hfProjectId.Value = projectId.ToString(); lblAssessmentOrder.Text = projectPointOfAssessment.AssessmentOrder.ToString(); tbAssessmentText.Text = projectPointOfAssessment.AssessmentText; ddlPointOfAssessmentTypeValue.SetValue(projectPointOfAssessment.PointOfAssessmentTypeValueId); // render UI based on Authorized and IsSystem bool readOnly = false; nbEditModeMessage.Text = string.Empty; if (!IsUserAuthorized("Edit")) { readOnly = true; nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed("Point of Assessment"); } if (readOnly) { lActionTitle.Text = ActionTitle.View("Point of Assessment " + projectPointOfAssessment.AssessmentOrder.ToString()); btnCancel.Text = "Close"; } tbAssessmentText.ReadOnly = readOnly; btnSave.Visible = !readOnly; }