/// <summary> /// Binds the project list grid. /// </summary> protected void BindGrid() { var competencyPersonProjectService = new ResidencyService <CompetencyPersonProject>(); int competencyPersonId = hfCompetencyPersonId.ValueAsInt(); SortProperty sortProperty = gProjectList.SortProperty; var qry = competencyPersonProjectService.Queryable(); qry = qry.Where(a => a.CompetencyPersonId.Equals(competencyPersonId)); if (sortProperty != null) { qry = qry.Sort(sortProperty); } else { qry = qry.OrderBy(s => s.Project.Name).ThenBy(s => s.Project.Description); } var resultList = qry.ToList().Select(a => new { Id = a.Id, Name = a.Project.Name, Description = a.Project.Description, MinAssessmentCount = a.MinAssessmentCount ?? a.Project.MinAssessmentCountDefault, AssessmentCompleted = a.CompetencyPersonProjectAssessments.Where(b => b.AssessmentDateTime != null).Count(), AssessmentRemaining = Math.Max(a.MinAssessmentCount ?? a.Project.MinAssessmentCountDefault - a.CompetencyPersonProjectAssessments.Where(b => b.AssessmentDateTime != null).Count() ?? 0, 0) }).ToList(); gProjectList.DataSource = resultList; gProjectList.DataBind(); }
/// <summary> /// Shows the detail. /// </summary> /// <param name="itemKey">The item key.</param> /// <param name="itemKeyValue">The item key value.</param> public void ShowDetail(string itemKey, int itemKeyValue) { // return if unexpected itemKey if (itemKey != "competencyPersonProjectId") { return; } pnlDetails.Visible = true; CompetencyPersonProject competencyPersonProject = new ResidencyService <CompetencyPersonProject>().Get(itemKeyValue); if (competencyPersonProject.CompetencyPerson.PersonId != CurrentPersonId) { // somebody besides the Resident is logged in Dictionary <string, string> queryString = new Dictionary <string, string>(); queryString.Add("competencyPersonId", competencyPersonProject.CompetencyPersonId.ToString()); NavigateToParentPage(queryString); return; } hfCompetencyPersonProjectId.Value = competencyPersonProject.Id.ToString(); ShowReadonlyDetails(competencyPersonProject); }
/// <summary> /// Returns breadcrumbs specific to the block that should be added to navigation /// based on the current page reference. This function is called during the page's /// oninit to load any initial breadcrumbs /// </summary> /// <param name="pageReference">The page reference.</param> /// <returns></returns> public override List <BreadCrumb> GetBreadCrumbs(PageReference pageReference) { var breadCrumbs = new List <BreadCrumb>(); int?competencyPersonProjectId = this.PageParameter(pageReference, "competencyPersonProjectId").AsInteger(); if (competencyPersonProjectId != null) { CompetencyPersonProject competencyPersonProject = new ResidencyService <CompetencyPersonProject>().Get(competencyPersonProjectId.Value); if (competencyPersonProject != null) { breadCrumbs.Add(new BreadCrumb(competencyPersonProject.Project.Name, pageReference)); } else { breadCrumbs.Add(new BreadCrumb("Project", pageReference)); } } else { // don't show a breadcrumb if we don't have a pageparam to work with } return(breadCrumbs); }
/// <summary> /// Shows the detail. /// </summary> /// <param name="itemKey">The item key.</param> /// <param name="itemKeyValue">The item key value.</param> /// <param name="personId">The person id.</param> public void ShowDetail(string itemKey, int itemKeyValue, int?personId) { // return if unexpected itemKey if (itemKey != "competencyPersonId") { return; } pnlDetails.Visible = true; // Load depending on Add(0) or Edit CompetencyPerson competencyPerson = null; if (!itemKeyValue.Equals(0)) { competencyPerson = new ResidencyService <CompetencyPerson>().Get(itemKeyValue); } else { competencyPerson = new CompetencyPerson { Id = 0 }; competencyPerson.PersonId = personId ?? 0; competencyPerson.Person = new ResidencyService <Person>().Get(competencyPerson.PersonId); } hfCompetencyPersonId.Value = competencyPerson.Id.ToString(); hfPersonId.Value = competencyPerson.PersonId.ToString(); // render UI based on Authorized and IsSystem bool readOnly = false; nbEditModeMessage.Text = string.Empty; if (!IsUserAuthorized("Edit")) { readOnly = true; nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(CompetencyPerson.FriendlyTypeName); } if (readOnly) { btnEdit.Visible = false; ShowReadonlyDetails(competencyPerson); } else { // don't allow edit once a Competency has been assign btnEdit.Visible = false; if (competencyPerson.Id > 0) { ShowReadonlyDetails(competencyPerson); } else { ShowEditDetails(competencyPerson); } } }
/// <summary> /// Handles the SelectedIndexChanged event of the ddlPeriodTrack 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 ddlPeriod_SelectedIndexChanged(object sender, EventArgs e) { int periodId = ddlPeriod.SelectedValueAsInt() ?? 0; var trackQry = new ResidencyService <Track>().Queryable().Where(a => a.PeriodId.Equals(periodId)); ddlTrack.DataSource = trackQry.OrderBy(a => a.DisplayOrder).ThenBy(a => a.Name).ToList(); ddlTrack.DataBind(); ddlTrack_SelectedIndexChanged(null, null); }
/// <summary> /// Shows the detail. /// </summary> /// <param name="itemKey">The item key.</param> /// <param name="itemKeyValue">The item key value.</param> /// <param name="periodId">The period id.</param> public void ShowDetail(string itemKey, int itemKeyValue, int?periodId) { // return if unexpected itemKey if (itemKey != "trackId") { return; } pnlDetails.Visible = true; // Load depending on Add(0) or Edit Track track = null; if (!itemKeyValue.Equals(0)) { track = new ResidencyService <Track>().Get(itemKeyValue); } else { track = new Track { Id = 0 }; track.PeriodId = periodId ?? 0; track.Period = new ResidencyService <Period>().Get(track.PeriodId); } hfTrackId.Value = track.Id.ToString(); hfPeriodId.Value = track.PeriodId.ToString(); // render UI based on Authorized and IsSystem bool readOnly = false; nbEditModeMessage.Text = string.Empty; if (!IsUserAuthorized("Edit")) { readOnly = true; nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(Track.FriendlyTypeName); } if (readOnly) { btnEdit.Visible = false; ShowReadonlyDetails(track); } else { btnEdit.Visible = true; if (track.Id > 0) { ShowReadonlyDetails(track); } else { ShowEditDetails(track); } } }
/// <summary> /// Handles the SelectedIndexChanged event of the ddlProject 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 ddlProject_SelectedIndexChanged(object sender, EventArgs e) { var project = new ResidencyService <Project>().Get(ddlProject.SelectedValueAsInt() ?? 0); if (project != null) { lblMinAssessmentCountDefault.Text = project.MinAssessmentCountDefault.ToString(); } }
/// <summary> /// Binds the grid. /// </summary> private void BindGrid() { SortProperty sortProperty = gList.SortProperty; int competencyPersonProjectAssessmentId = hfCompetencyPersonProjectAssessmentId.ValueAsInt(); List <CompetencyPersonProjectAssessmentPointOfAssessment> personPointOfAssessmentList = new ResidencyService <CompetencyPersonProjectAssessmentPointOfAssessment>().Queryable() .Where(a => a.CompetencyPersonProjectAssessmentId.Equals(competencyPersonProjectAssessmentId)).ToList(); CompetencyPersonProjectAssessment competencyPersonProjectAssessment = new ResidencyService <CompetencyPersonProjectAssessment>().Get(competencyPersonProjectAssessmentId); List <ProjectPointOfAssessment> projectPointOfAssessmentList; if (competencyPersonProjectAssessment != null) { projectPointOfAssessmentList = new ResidencyService <ProjectPointOfAssessment>().Queryable() .Where(a => a.ProjectId.Equals(competencyPersonProjectAssessment.CompetencyPersonProject.ProjectId)).ToList(); } else { projectPointOfAssessmentList = new List <ProjectPointOfAssessment>(); } foreach (var item in projectPointOfAssessmentList) { if (item.PointOfAssessmentTypeValue != null) { item.PointOfAssessmentTypeValue.LoadAttributes(); } } var joinedItems = from projectPointOfAssessment in projectPointOfAssessmentList join personPointOfAssessment in personPointOfAssessmentList on projectPointOfAssessment.Id equals personPointOfAssessment.ProjectPointOfAssessmentId into groupJoin from qryResult in groupJoin.DefaultIfEmpty() select new { // note: two key fields, since we want to show all the Points of Assessment for this Project, if the person hasn't had a rating on it yet ProjectPointOfAssessmentId = projectPointOfAssessment.Id, CompetencyPersonProjectAssessmentId = competencyPersonProjectAssessmentId, ProjectPointOfAssessmentColor = projectPointOfAssessment.PointOfAssessmentTypeValue != null?projectPointOfAssessment.PointOfAssessmentTypeValue.GetAttributeValue("Color") : string.Empty, ProjectPointOfAssessment = projectPointOfAssessment, CompetencyPersonProjectAssessmentPointOfAssessment = personPointOfAssessmentList.FirstOrDefault(a => a.ProjectPointOfAssessmentId.Equals(projectPointOfAssessment.Id)) }; if (sortProperty != null) { gList.DataSource = joinedItems.AsQueryable().Sort(sortProperty).ToList(); } else { gList.DataSource = joinedItems.OrderBy(s => s.ProjectPointOfAssessment.AssessmentOrder).ToList(); } gList.DataBind(); }
/// <summary> /// Shows the detail. /// </summary> /// <param name="itemKey">The item key.</param> /// <param name="itemKeyValue">The item key value.</param> public void ShowDetail(string itemKey, int itemKeyValue) { // return if unexpected itemKey if (itemKey != "periodId") { return; } pnlDetails.Visible = true; // Load depending on Add(0) or Edit Period period = null; if (!itemKeyValue.Equals(0)) { period = new ResidencyService <Period>().Get(itemKeyValue); lActionTitle.Text = ActionTitle.Edit(Period.FriendlyTypeName); } else { period = new Period { Id = 0 }; lActionTitle.Text = ActionTitle.Add(Period.FriendlyTypeName); } hfPeriodId.Value = period.Id.ToString(); // render UI based on Authorized and IsSystem bool readOnly = false; nbEditModeMessage.Text = string.Empty; if (!IsUserAuthorized("Edit")) { readOnly = true; nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(Period.FriendlyTypeName); } if (readOnly) { btnEdit.Visible = false; ShowReadonlyDetails(period); } else { btnEdit.Visible = true; if (period.Id > 0) { ShowReadonlyDetails(period); } else { ShowEditDetails(period); } } }
/// <summary> /// Handles the GridReorder event of the gList control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="GridReorderEventArgs"/> instance containing the event data.</param> /// <exception cref="System.NotImplementedException"></exception> protected void gList_GridReorder(object sender, GridReorderEventArgs e) { int oldIndex = e.OldIndex; int newIndex = e.NewIndex; int periodId = hfPeriodId.ValueAsInt(); var trackService = new ResidencyService <Track>(); var items = trackService.Queryable() .Where(a => a.PeriodId.Equals(periodId)) .OrderBy(a => a.DisplayOrder).ToList(); RockTransactionScope.WrapTransaction(() => { Track movedItem = items[oldIndex]; items.RemoveAt(oldIndex); if (newIndex >= items.Count) { items.Add(movedItem); } else { items.Insert(newIndex, movedItem); } int order = 1; foreach (Track item in items) { if (item != null) { if (item.DisplayOrder != order) { // temporarily, set the order to negative in case another row has this value. item.DisplayOrder = -order; trackService.Save(item, CurrentPersonId); } } order++; } foreach (Track item in items) { if (item != null) { if (item.DisplayOrder < 0) { // update the value back to positive now that all the rows have their new order item.DisplayOrder = -item.DisplayOrder; trackService.Save(item, 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) { 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="competencyId">The residency competency id.</param> public void ShowDetail(string itemKey, int itemKeyValue, int?competencyId) { // return if unexpected itemKey if (itemKey != "projectId") { return; } pnlDetails.Visible = true; Project project = null; if (!itemKeyValue.Equals(0)) { project = new ResidencyService <Project>().Get(itemKeyValue); } else { project = new Project { Id = 0 }; project.CompetencyId = competencyId ?? 0; project.Competency = new ResidencyService <Competency>().Get(project.CompetencyId); } hfProjectId.Value = project.Id.ToString(); hfCompetencyId.Value = project.CompetencyId.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.FriendlyTypeName); } if (readOnly) { btnEdit.Visible = false; ShowReadonlyDetails(project); } else { btnEdit.Visible = true; if (project.Id > 0) { ShowReadonlyDetails(project); } else { ShowEditDetails(project); } } }
/// <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 residencyGroupMemberService = new ResidencyService <Rock.Model.GroupMember>(); int residencyGroupId = PageParameter("groupId").AsInteger() ?? 0; hfGroupId.SetValue(residencyGroupId); var residencyGroupMemberList = residencyGroupMemberService.Queryable() .Where(a => a.GroupId.Equals(residencyGroupId)).ToList(); var competencyPersonService = new ResidencyService <CompetencyPerson>(); List <IGrouping <int, CompetencyPerson> > competencyPersonQry = competencyPersonService.Queryable().GroupBy(a => a.PersonId).ToList(); var groupMemberCompetencies = from groupMember in residencyGroupMemberList join competencyList in competencyPersonQry on groupMember.PersonId equals competencyList.Key into groupJoin from qryResult in groupJoin.DefaultIfEmpty() select new { GroupMember = groupMember, ResidentCompentencies = qryResult != null?qryResult.ToList() : null }; var dataResult = groupMemberCompetencies.Select(a => new { Id = a.GroupMember.Id, FullName = a.GroupMember.Person.FullName, CompetencyCount = a.ResidentCompentencies == null ? 0 : a.ResidentCompentencies.Count(), CompletedProjectAssessmentsTotal = a.ResidentCompentencies == null ? 0 : a.ResidentCompentencies.SelectMany(cp => cp.CompetencyPersonProjects).SelectMany(x => x.CompetencyPersonProjectAssessments).Where(y => y.AssessmentDateTime != null).Count(), MinAssessmentCount = a.ResidentCompentencies == null ? 0 : a.ResidentCompentencies.SelectMany(cp => cp.CompetencyPersonProjects).Select(x => x.MinAssessmentCount ?? x.Project.MinAssessmentCountDefault ?? 0).Sum(), }); SortProperty sortProperty = gList.SortProperty; if (sortProperty != null) { gList.DataSource = dataResult.AsQueryable().Sort(sortProperty).ToList(); } else { gList.DataSource = dataResult.OrderBy(s => s.FullName).ToList(); } gList.DataBind(); }
/// <summary> /// Shows the detail. /// </summary> /// <param name="itemKey">The item key.</param> /// <param name="itemKeyValue">The item key value.</param> public void ShowDetail(string itemKey, int itemKeyValue) { // return if unexpected itemKey if (itemKey != "personId") { return; } pnlDetails.Visible = true; // this is always just a View block (they are added/edited on the GroupMember block) Person person = new ResidencyService <Person>().Get(itemKeyValue); ShowReadonlyDetails(person); }
/// <summary> /// Binds the repeater. /// </summary> private void BindRepeater() { var trackService = new ResidencyService <Track>(); var competencyPersonService = new ResidencyService <CompetencyPerson>(); int currentPersonId = this.CurrentPersonId ?? 0; List <int> residentCompetencyIds = competencyPersonService.Queryable().Where(a => a.PersonId.Equals(currentPersonId)) .Select(x => x.CompetencyId).Distinct().ToList(); var qryPersonTracks = trackService.Queryable().Where(a => residentCompetencyIds.Any(rc => a.Competencies.Select(c => c.Id).Contains(rc))) .OrderBy(o => o.DisplayOrder); rpTracks.DataSource = qryPersonTracks.ToList(); rpTracks.DataBind(); }
/// <summary> /// Binds the grid. /// </summary> private void BindGrid() { var periodService = new ResidencyService <Period>(); SortProperty sortProperty = gList.SortProperty; if (sortProperty != null) { gList.DataSource = periodService.Queryable().Sort(sortProperty).ToList(); } else { gList.DataSource = periodService.Queryable().OrderBy(s => s.Name).ToList(); } gList.DataBind(); }
/// <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 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) { 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> /// Shows the detail. /// </summary> /// <param name="itemKey">The item key.</param> /// <param name="itemKeyValue">The item key value.</param> public void ShowDetail(string itemKey, int itemKeyValue) { // return if unexpected itemKey if (itemKey != "competencyPersonId") { return; } pnlDetails.Visible = true; CompetencyPerson competencyPerson = new ResidencyService <CompetencyPerson>().Get(itemKeyValue); if (competencyPerson != null) { lblGoals.Text = (competencyPerson.Competency.Goals ?? string.Empty).Replace("\n", "<br>"); } }
/// <summary> /// Raises the <see cref="E:System.Web.UI.Control.Load" /> event. /// </summary> /// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param> protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (!Page.IsPostBack) { // allow this block to work with either a personId or groupMemberId parameter int personId = this.PageParameter("personId").AsInteger() ?? 0; if (personId == 0) { int groupMemberId = this.PageParameter("groupMemberId").AsInteger() ?? 0; personId = new ResidencyService <GroupMember>().Queryable().Where(a => a.Id.Equals(groupMemberId)).Select(a => a.PersonId).FirstOrDefault(); } hfPersonId.Value = personId.ToString(); 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) { 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 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 groupMemberService = new GroupMemberService(); int groupMemberId = (int)e.RowKeyValue; GroupMember groupMember = groupMemberService.Get(groupMemberId); if (groupMember != null) { // check if person can be removed from the Group and also check if person can be removed from all the person assigned competencies string errorMessage; if (!groupMemberService.CanDelete(groupMember, out errorMessage)) { mdGridWarning.Show(errorMessage, ModalAlertType.Information); return; } var competencyPersonService = new ResidencyService <CompetencyPerson>(); var personCompetencyList = competencyPersonService.Queryable().Where(a => a.PersonId.Equals(groupMember.PersonId)); foreach (var item in personCompetencyList) { if (!competencyPersonService.CanDelete(item, out errorMessage)) { mdGridWarning.Show(errorMessage, ModalAlertType.Information); return; } } // if you made it this far, delete all person's assigned competencies, and finally delete from Group foreach (var item in personCompetencyList) { competencyPersonService.Delete(item, CurrentPersonId); competencyPersonService.Save(item, CurrentPersonId); } groupMemberService.Delete(groupMember, CurrentPersonId); groupMemberService.Save(groupMember, 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) { 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> /// Loads the drop downs. /// </summary> protected void LoadDropDowns() { string groupId = this.GetAttributeValue("ResidencyGraderSecurityRole"); List <Person> facilitatorList = new List <Person>(); Group residencyGraderSecurityRole = new GroupService().Get(groupId.AsInteger() ?? 0); if (residencyGraderSecurityRole != null) { foreach (var groupMember in residencyGraderSecurityRole.Members) { facilitatorList.Add(groupMember.Person); } } CompetencyPersonProject competencyPersonProject = new ResidencyService <CompetencyPersonProject>().Get(hfCompetencyPersonProjectId.ValueAsInt()); if (competencyPersonProject != null) { if (competencyPersonProject.Project.Competency.TeacherOfRecordPerson != null) { if (!facilitatorList.Contains(competencyPersonProject.Project.Competency.TeacherOfRecordPerson)) { facilitatorList.Add(competencyPersonProject.Project.Competency.TeacherOfRecordPerson); } } } if (facilitatorList.Any()) { nbSendMessage.Text = string.Empty; ddlFacilitators.DataSource = facilitatorList; ddlFacilitators.DataBind(); } else { nbSendMessage.NotificationBoxType = Rock.Web.UI.Controls.NotificationBoxType.Error; nbSendMessage.Text = "No facilitators configured"; } }
/// <summary> /// Binds the grid. /// </summary> private void BindGrid() { var competencyPersonProjectAssessmentService = new ResidencyService <CompetencyPersonProjectAssessment>(); int competencyPersonProjectId = hfCompetencyPersonProjectId.ValueAsInt(); SortProperty sortProperty = gList.SortProperty; var qry = competencyPersonProjectAssessmentService.Queryable(); qry = qry.Where(a => a.CompetencyPersonProjectId.Equals(competencyPersonProjectId)); if (sortProperty != null) { qry = qry.Sort(sortProperty); } else { qry = qry.OrderByDescending(s => s.AssessmentDateTime); } gList.DataSource = qry.ToList(); gList.DataBind(); }
/// <summary> /// Binds the grid. /// </summary> private void BindGrid() { var trackService = new ResidencyService <Track>(); int periodId = hfPeriodId.ValueAsInt(); SortProperty sortProperty = gList.SortProperty; var qry = trackService.Queryable(); qry = qry.Where(a => a.PeriodId.Equals(periodId)); if (sortProperty != null) { qry = qry.Sort(sortProperty); } else { qry = qry.OrderBy(s => s.DisplayOrder).ThenBy(s => s.Name); } gList.DataSource = qry.ToList(); gList.DataBind(); }
/// <summary> /// Binds the grid. /// </summary> private void BindGrid() { var projectService = new ResidencyService <Project>(); int competencyId = hfCompetencyId.ValueAsInt(); SortProperty sortProperty = gList.SortProperty; var qry = projectService.Queryable(); qry = qry.Where(a => a.CompetencyId.Equals(competencyId)); if (sortProperty != null) { qry = qry.Sort(sortProperty); } else { qry = qry.OrderBy(s => s.Name); } gList.DataSource = qry.ToList(); gList.DataBind(); }