/// <summary> /// Gets or sets the group. /// </summary> /// <param name="rockContext">The rock context.</param> /// <returns></returns> /// <value> /// The group. /// </value> public Group GetGroup(RockContext rockContext) { EnsureChildControls(); Group result = new Group(); result.Id = _hfGroupTypeId.ValueAsInt(); result.Guid = new Guid(_hfGroupGuid.Value); result.GroupTypeId = _hfGroupTypeId.ValueAsInt(); // get the current InheritedGroupTypeId from the Parent Editor just in case it hasn't been saved to the database CheckinGroupTypeEditor checkinGroupTypeEditor = GetParentGroupTypeEditor(this.Parent); if (checkinGroupTypeEditor != null) { result.GroupType = new GroupType(); result.GroupType.Id = result.GroupTypeId; result.GroupType.Guid = checkinGroupTypeEditor.GroupTypeGuid; result.GroupType.InheritedGroupTypeId = checkinGroupTypeEditor.InheritedGroupTypeId; } result.Name = _tbGroupName.Text; result.LoadAttributes(rockContext); // populate groupLocations with whatever is currently in the grid, with just enough info to repopulate it and save it later result.GroupLocations = new List <GroupLocation>(); foreach (var item in this.Locations) { var groupLocation = new GroupLocation(); groupLocation.LocationId = item.LocationId; groupLocation.Location = new Location { Id = item.LocationId, Name = item.Name, ParentLocationId = item.ParentLocationId }; result.GroupLocations.Add(groupLocation); } result.Groups = new List <Group>(); int childGroupOrder = 0; foreach (CheckinGroupEditor checkinGroupEditor in this.Controls.OfType <CheckinGroupEditor>()) { Group childGroup = checkinGroupEditor.GetGroup(rockContext); childGroup.Order = childGroupOrder++; result.Groups.Add(childGroup); } Rock.Attribute.Helper.GetEditValues(_phGroupAttributes, result); return(result); }
/// <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) { LinkButton btn = ( LinkButton )sender; RepeaterItem item = ( RepeaterItem )btn.NamingContainer; HiddenField hfShortcodeId = ( HiddenField )item.FindControl("hfShortcodeId"); NavigateToLinkedPage("DetailPage", "lavaShortcodeId", hfShortcodeId.ValueAsInt()); }
/// <summary> /// Gets the type of the checkin group. /// </summary> /// <param name="rockContext">The rock context.</param> /// <returns></returns> public GroupType GetCheckinGroupType(RockContext rockContext) { EnsureChildControls(); GroupType result = new GroupType(); //// NOTE: A GroupType that was added will have an Id of 0 since it hasn't been saved to the database. //// So, we'll use Guid to uniquely identify in this Control since that'll work in both Saved and Unsaved cases. //// If it is saved, we do need the Id so that Attributes will work result.Id = _hfGroupTypeId.ValueAsInt(); result.Guid = new Guid(_hfGroupTypeGuid.Value); result.Name = _tbGroupTypeName.Text; result.InheritedGroupTypeId = _ddlGroupTypeInheritFrom.SelectedValueAsId(); result.LoadAttributes(rockContext); Rock.Attribute.Helper.GetEditValues(_phGroupTypeAttributes, result); result.ChildGroupTypes = new List <GroupType>(); int childGroupTypeOrder = 0; foreach (CheckinGroupTypeEditor checkinGroupTypeEditor in this.Controls.OfType <CheckinGroupTypeEditor>()) { GroupType childGroupType = checkinGroupTypeEditor.GetCheckinGroupType(rockContext); childGroupType.Order = childGroupTypeOrder++; result.ChildGroupTypes.Add(childGroupType); } result.Groups = new List <Group>(); int childGroupOrder = 0; foreach (CheckinGroupEditor checkinGroupEditor in this.Controls.OfType <CheckinGroupEditor>()) { Group childGroup = checkinGroupEditor.GetGroup(rockContext); childGroup.Order = childGroupOrder++; result.Groups.Add(childGroup); } return(result); }
private void LoadValuesFromPage() { foreach (var item in rptBucketRepeater.Items.OfType <RepeaterItem>()) { HiddenField BucketId = item.FindControl("hfBucketId") as HiddenField; HiddenField BucketOrder = item.FindControl("hfSortOrder") as HiddenField; RockTextBox tbDisplayName = item.FindControl("tbDisplayName") as RockTextBox; Bucket thisBucket = _buckets.Find((b) => b.Id == BucketId.ValueAsInt()); thisBucket.DisplayAs = tbDisplayName.Text; thisBucket.Order = Int32.Parse(BucketOrder.Value); } }
/// <summary> /// Gets or sets the type of the workflow activity. /// </summary> /// <value> /// The type of the workflow activity. /// </value> public RegistrationTemplateForm GetForm(bool expandInvalid) { EnsureChildControls(); RegistrationTemplateForm result = new RegistrationTemplateForm(); result.Id = _hfFormId.ValueAsInt(); result.Guid = new Guid(_hfFormGuid.Value); result.Name = _tbFormName.Text; if (expandInvalid && !Expanded && !result.IsValid) { Expanded = true; } return(result); }
/// <summary> /// Gets the ignore campus changes repeater data. /// </summary> private void GetIgnoreCampusChangesRepeaterData() { _ignoreCampusChangeRows = new List <IgnoreCampusChangeRow>(); foreach (RepeaterItem item in rptIgnoreCampusChanges.Items) { CampusPicker fromCampus = item.FindControl("cpFromCampus") as CampusPicker; CampusPicker toCampus = item.FindControl("cpToCampus") as CampusPicker; HiddenField hiddenField = item.FindControl("hfRowId") as HiddenField; RockDropDownList ddlCampusCriteria = item.FindControl("ddlAttendanceOrGiving") as RockDropDownList; _ignoreCampusChangeRows.Add(new IgnoreCampusChangeRow { Id = hiddenField.ValueAsInt(), ToCampusId = toCampus.SelectedCampusId, FromCampusId = fromCampus.SelectedCampusId, CampusCriteria = ddlCampusCriteria.SelectedValueAsEnumOrNull <CampusCriteria>() }); } }
/// <summary> /// Handles the Click event of the btnDelete 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 btnDelete_Click(object sender, EventArgs e) { LinkButton btn = ( LinkButton )sender; RepeaterItem item = ( RepeaterItem )btn.NamingContainer; HiddenField hfShortcodeId = ( HiddenField )item.FindControl("hfShortcodeId"); var rockContext = new RockContext(); LavaShortcodeService lavaShortcodeService = new LavaShortcodeService(rockContext); LavaShortcode lavaShortcode = lavaShortcodeService.Get(hfShortcodeId.ValueAsInt()); if (lavaShortcode != null) { // unregister the shortcode Template.UnregisterShortcode(lavaShortcode.TagName); lavaShortcodeService.Delete(lavaShortcode); rockContext.SaveChanges(); } LoadShortcodes(); }
protected void SavePersonDetails(Person person, RockContext rockContext) { person.NickName = tbNickName.Text; person.TitleValueId = dvpTitle.SelectedValue.AsIntegerOrNull(); person.FirstName = tbFirstName.Text; person.MiddleName = tbMiddleName.Text; person.LastName = tbLastName.Text; person.SuffixValueId = dvpSuffix.SelectedValue.AsIntegerOrNull(); person.Gender = rblGender.SelectedValueAsEnum <Gender>(); person.SetBirthDate(bpBirthday.SelectedDate); person.GradeOffset = gpGrade.SelectedValue.AsIntegerOrNull(); person.LoadAttributes(); person.SetAttributeValue("Allergy", rtbAllergy.Text); var newPhoneNumbers = new List <PhoneNumber>(); foreach (RepeaterItem item in rContactInfo.Items) { HiddenField hfPhoneType = item.FindControl("hfPhoneType") as HiddenField; PhoneNumberBox pnbPhone = item.FindControl("pnbPhone") as PhoneNumberBox; CheckBox cbUnlisted = item.FindControl("cbUnlisted") as CheckBox; if (hfPhoneType != null && pnbPhone != null && cbUnlisted != null) { var countryCode = PhoneNumber.CleanNumber(pnbPhone.CountryCode); var phoneNumber = PhoneNumber.CleanNumber(pnbPhone.Number); if (!string.IsNullOrWhiteSpace(countryCode) && !string.IsNullOrWhiteSpace(phoneNumber)) { newPhoneNumbers.Add(new PhoneNumber { NumberTypeValueId = hfPhoneType.ValueAsInt(), Number = phoneNumber, CountryCode = countryCode, IsMessagingEnabled = false, IsUnlisted = cbUnlisted.Checked }); } } } foreach (PhoneNumber oldPhoneNumber in person.PhoneNumbers.ToList()) { var matchingPhoneNumber = newPhoneNumbers.FirstOrDefault(pn => pn.NumberTypeValueId == oldPhoneNumber.NumberTypeValueId); if (matchingPhoneNumber != null) { oldPhoneNumber.CountryCode = matchingPhoneNumber.CountryCode; oldPhoneNumber.Number = matchingPhoneNumber.Number; oldPhoneNumber.IsUnlisted = matchingPhoneNumber.IsUnlisted; newPhoneNumbers.Remove(matchingPhoneNumber); } else { person.PhoneNumbers.Remove(oldPhoneNumber); new PhoneNumberService(rockContext).Delete(oldPhoneNumber); } } foreach (PhoneNumber newPhoneNumber in newPhoneNumbers) { person.PhoneNumbers.Add(newPhoneNumber); } }
/// <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"); } }