/// <summary> /// Creates the child controls. /// </summary> /// <param name="parentControl"></param> /// <returns></returns> public override System.Web.UI.Control[] CreateChildControls(System.Web.UI.Control parentControl) { var cblNoteTypes = new RockListBox(); cblNoteTypes.ID = parentControl.GetChildControlInstanceName(_CtlNoteTypes); cblNoteTypes.Label = "Note Types"; cblNoteTypes.Help = "The type of note to filter by. Leave blank to include all note types."; parentControl.Controls.Add(cblNoteTypes); var noteTypeService = new NoteTypeService(new RockContext()); var entityTypeIdPerson = EntityTypeCache.GetId <Rock.Model.Person>(); var noteTypes = noteTypeService.Queryable() .Where(a => a.EntityTypeId == entityTypeIdPerson) .OrderBy(a => a.Order) .ThenBy(a => a.Name) .Select(a => new { a.Id, a.Name }).ToList(); cblNoteTypes.Items.Clear(); cblNoteTypes.Items.AddRange(noteTypes.Select(a => new ListItem(a.Name, a.Id.ToString())).ToArray()); var slidingDateRangePicker = new SlidingDateRangePicker(); slidingDateRangePicker.ID = parentControl.GetChildControlInstanceName(_CtlSlidingDateRangePicker); slidingDateRangePicker.Label = "Date Range"; slidingDateRangePicker.Help = "The date range that the note was created during."; slidingDateRangePicker.Required = false; parentControl.Controls.Add(slidingDateRangePicker); return(new System.Web.UI.Control[] { cblNoteTypes, slidingDateRangePicker }); }
/// <summary> /// Creates the child controls. /// </summary> /// <returns></returns> public override Control[] CreateChildControls(Type entityType, FilterField filterControl) { RockDropDownList ddlNoteType = new RockDropDownList(); ddlNoteType.ID = filterControl.ID + "_ddlNoteType"; ddlNoteType.CssClass = "js-notetype"; ddlNoteType.Label = "Note Type"; filterControl.Controls.Add(ddlNoteType); var noteTypeService = new NoteTypeService(new RockContext()); var entityTypeIdPerson = EntityTypeCache.GetId <Rock.Model.Person>(); var noteTypes = noteTypeService.Queryable().Where(a => a.EntityTypeId == entityTypeIdPerson) .OrderBy(a => a.Order) .ThenBy(a => a.Name) .Select(a => new { a.Id, a.Name }).ToList(); ddlNoteType.Items.Clear(); ddlNoteType.Items.Add(new ListItem()); ddlNoteType.Items.AddRange(noteTypes.Select(a => new ListItem(a.Name, a.Id.ToString())).ToArray()); var tbContains = new RockTextBox(); tbContains.Label = "Contains"; tbContains.ID = filterControl.ID + "_tbContains"; tbContains.CssClass = "js-notecontains"; filterControl.Controls.Add(tbContains); return(new System.Web.UI.Control[2] { ddlNoteType, tbContains }); }
private static int LoadByGuid2(Guid guid, RockContext rockContext) { var NoteTypeService = new NoteTypeService(rockContext); return(NoteTypeService .Queryable().AsNoTracking() .Where(c => c.Guid.Equals(guid)) .Select(c => c.Id) .FirstOrDefault()); }
/// <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 noteTypeId = hfNoteTypeId.Value.AsInteger(); var rockContext = new RockContext(); var service = new NoteTypeService(rockContext); NoteType noteType = null; if (noteTypeId != 0) { noteType = service.Get(noteTypeId); } int entityTypeId = epEntityType.SelectedEntityTypeId ?? 0; if (noteType == null) { int?maxNoteTypeOrderForEntity = service.Queryable().Where(t => t.EntityTypeId == entityTypeId).Max(a => ( int? )a.Order); noteType = new NoteType(); noteType.Order = (maxNoteTypeOrderForEntity ?? 0) + 1; service.Add(noteType); } noteType.Name = tbName.Text; noteType.EntityTypeId = entityTypeId; noteType.EntityTypeQualifierColumn = string.Empty; noteType.EntityTypeQualifierValue = string.Empty; noteType.IconCssClass = tbIconCssClass.Text; noteType.BackgroundColor = cpBackgroundColor.Text; noteType.FontColor = cpFontColor.Text; noteType.BorderColor = cpBorderColor.Text; noteType.UserSelectable = cbUserSelectable.Checked; noteType.RequiresApprovals = cbRequiresApprovals.Checked; noteType.SendApprovalNotifications = cbSendApprovalNotifications.Checked; noteType.AllowsWatching = cbAllowsWatching.Checked; noteType.AutoWatchAuthors = cbAutoWatchAuthors.Checked; noteType.AllowsReplies = cbAllowsReplies.Checked; noteType.MaxReplyDepth = nbMaxReplyDepth.Text.AsIntegerOrNull(); noteType.AllowsAttachments = cbAllowsAttachments.Checked; noteType.BinaryFileTypeId = noteType.AllowsAttachments ? bftpAttachmentType.SelectedValueAsId() : null; noteType.ApprovalUrlTemplate = ceApprovalUrlTemplate.Text; if (noteType.IsValid) { rockContext.SaveChanges(); } NavigateToParentPage(); }
/// <summary> /// Handles the SaveClick event of the modalDetails 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 modalDetails_SaveClick(object sender, EventArgs e) { int noteTypeId = 0; if (hfIdValue.Value != string.Empty && !int.TryParse(hfIdValue.Value, out noteTypeId)) { noteTypeId = 0; } var rockContext = new RockContext(); var service = new NoteTypeService(rockContext); NoteType noteType = null; if (noteTypeId != 0) { noteType = service.Get(noteTypeId); } if (noteType == null) { var orders = service.Queryable() .Where(t => t.EntityTypeId == (entityTypePicker.SelectedEntityTypeId ?? 0)) .Select(t => t.Order) .ToList(); noteType = new NoteType(); noteType.Order = orders.Any() ? orders.Max(t => t) + 1 : 0; service.Add(noteType); } noteType.Name = tbName.Text; noteType.EntityTypeId = entityTypePicker.SelectedEntityTypeId ?? 0; noteType.EntityTypeQualifierColumn = ""; noteType.EntityTypeQualifierValue = ""; noteType.UserSelectable = cbUserSelectable.Checked; noteType.CssClass = tbCssClass.Text; noteType.IconCssClass = tbIconCssClass.Text; if (noteType.IsValid) { rockContext.SaveChanges(); NoteTypeCache.Flush(noteType.Id); NoteTypeCache.FlushEntityNoteTypes(); hfIdValue.Value = string.Empty; modalDetails.Hide(); BindFilter(); BindGrid(); } }
/// <summary> /// Handles the SaveClick event of the modalDetails 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 modalDetails_SaveClick( object sender, EventArgs e ) { int noteTypeId = 0; if ( hfIdValue.Value != string.Empty && !int.TryParse( hfIdValue.Value, out noteTypeId ) ) { noteTypeId = 0; } var rockContext = new RockContext(); var service = new NoteTypeService( rockContext ); NoteType noteType = null; if ( noteTypeId != 0 ) { noteType = service.Get( noteTypeId ); } if ( noteType == null ) { var orders = service.Queryable() .Where( t => t.EntityTypeId == ( entityTypePicker.SelectedEntityTypeId ?? 0 ) ) .Select( t => t.Order ) .ToList(); noteType = new NoteType(); noteType.Order = orders.Any() ? orders.Max( t => t ) + 1 : 0; service.Add( noteType ); } noteType.Name = tbName.Text; noteType.EntityTypeId = entityTypePicker.SelectedEntityTypeId ?? 0; noteType.EntityTypeQualifierColumn = ""; noteType.EntityTypeQualifierValue = ""; noteType.UserSelectable = cbUserSelectable.Checked; noteType.CssClass = tbCssClass.Text; noteType.IconCssClass = tbIconCssClass.Text; if ( noteType.IsValid ) { rockContext.SaveChanges(); NoteTypeCache.Flush( noteType.Id ); NoteTypeCache.FlushEntityNoteTypes(); hfIdValue.Value = string.Empty; modalDetails.Hide(); BindFilter(); BindGrid(); } }
/// <summary> /// Creates the child controls. /// </summary> /// <returns></returns> public override Control[] CreateChildControls(Type entityType, FilterField filterControl) { var cblNoteTypes = new RockListBox(); cblNoteTypes.ID = filterControl.GetChildControlInstanceName(_CtlNoteTypes); cblNoteTypes.CssClass = "js-notetypes"; cblNoteTypes.Label = "Note Types"; cblNoteTypes.Help = "The type of note to filter by. Leave blank to include all note types."; filterControl.Controls.Add(cblNoteTypes); var noteTypeService = new NoteTypeService(new RockContext()); var entityTypeIdPerson = EntityTypeCache.GetId <Rock.Model.Person>(); var noteTypes = noteTypeService.Queryable().Where(a => a.EntityTypeId == entityTypeIdPerson) .OrderBy(a => a.Order) .ThenBy(a => a.Name) .Select(a => new { a.Id, a.Name }).ToList(); cblNoteTypes.Items.Clear(); cblNoteTypes.Items.AddRange(noteTypes.Select(a => new ListItem(a.Name, a.Id.ToString())).ToArray()); var slidingDateRangePicker = new SlidingDateRangePicker(); slidingDateRangePicker.ID = filterControl.GetChildControlInstanceName(_CtlSlidingDateRangePicker); slidingDateRangePicker.AddCssClass("js-sliding-date-range"); slidingDateRangePicker.Label = "Date Range"; slidingDateRangePicker.Help = "The date range that the note was created during."; slidingDateRangePicker.Required = false; filterControl.Controls.Add(slidingDateRangePicker); var nbMinimumCount = new NumberBox(); nbMinimumCount.ID = filterControl.GetChildControlInstanceName(_CtlMinimumCount); nbMinimumCount.NumberType = ValidationDataType.Integer; nbMinimumCount.MinimumValue = "1"; nbMinimumCount.Label = "Minimum Count"; nbMinimumCount.Help = "The minimum number of notes created during the date range to be considered a match."; nbMinimumCount.Required = true; nbMinimumCount.AddCssClass("js-minimum-count"); filterControl.Controls.Add(nbMinimumCount); return(new System.Web.UI.Control[3] { cblNoteTypes, slidingDateRangePicker, nbMinimumCount }); }
/// <summary> /// Creates the child controls. /// </summary> /// <returns></returns> public override Control[] CreateChildControls(Type entityType, FilterField filterControl) { RockDropDownList ddlNoteType = new RockDropDownList(); ddlNoteType.ID = filterControl.ID + "_ddlNoteType"; ddlNoteType.CssClass = "js-notetype"; ddlNoteType.Label = "Note Type"; filterControl.Controls.Add(ddlNoteType); var noteTypeService = new NoteTypeService(new RockContext()); var entityTypeIdPerson = EntityTypeCache.GetId <Rock.Model.Person>(); var noteTypes = noteTypeService.Queryable().Where(a => a.EntityTypeId == entityTypeIdPerson) .OrderBy(a => a.Order) .ThenBy(a => a.Name) .Select(a => new { a.Id, a.Name }).ToList(); ddlNoteType.Items.Clear(); ddlNoteType.Items.Add(new ListItem()); ddlNoteType.Items.AddRange(noteTypes.Select(a => new ListItem(a.Name, a.Id.ToString())).ToArray()); var tbContains = new RockTextBox(); tbContains.Label = "Contains"; tbContains.ID = filterControl.ID + "_tbContains"; tbContains.CssClass = "js-notecontains"; filterControl.Controls.Add(tbContains); var slidingDateRangePicker = new SlidingDateRangePicker(); slidingDateRangePicker.ID = filterControl.ID + "_slidingDateRangePicker"; slidingDateRangePicker.AddCssClass("js-sliding-date-range"); slidingDateRangePicker.Label = "Date Range"; slidingDateRangePicker.Help = "The date range of the note's creation date"; slidingDateRangePicker.Required = false; filterControl.Controls.Add(slidingDateRangePicker); return(new System.Web.UI.Control[3] { ddlNoteType, tbContains, slidingDateRangePicker }); }
private Note GetNoteForAttendanceDate(RockContext rockContext, bool createNew = false) { NoteTypeService noteTypeService = new NoteTypeService(rockContext); NoteType noteType = noteTypeService.Queryable().FirstOrDefault(nt => nt.Guid == new Guid("FFFC3644-60CD-4D14-A714-E8DCC202A0E1")); NoteService noteService = new NoteService(rockContext); var notes = noteService.Queryable().Where(n => n.NoteType.Guid == noteType.Guid && n.EntityId == CurrentGroup.Id).ToList(); foreach (Note note in notes) { note.LoadAttributes(); var dateString = note.GetAttributeValue("NoteDate"); DateTime parseDate; try { parseDate = DateTime.Parse(dateString); } catch { continue; } //if ( dateString != null && _occurrence != null && parseDate == _occurrence.Date ) //{ // return note; //} } if (createNew) { //Create new note if one does not exist. Note newNote = new Note(); newNote.NoteType = noteType; newNote.EntityId = CurrentGroup.Id; noteService.Add(newNote); rockContext.SaveChanges(); newNote.LoadAttributes(); //newNote.SetAttributeValue( "NoteDate", _occurrence.Date ); newNote.SaveAttributeValues(rockContext); rockContext.SaveChanges(); return(newNote); } return(null); }
/// <summary> /// Creates the child controls. /// </summary> /// <param name="parentControl"></param> /// <returns></returns> public override System.Web.UI.Control[] CreateChildControls(System.Web.UI.Control parentControl) { RockDropDownList ddlNoteType = new RockDropDownList(); ddlNoteType.ID = parentControl.ID + "_ddlNoteType"; ddlNoteType.Label = "Note Type"; parentControl.Controls.Add(ddlNoteType); var noteTypeService = new NoteTypeService(new RockContext()); var noteTypes = noteTypeService.Queryable().OrderBy(a => a.Order).ThenBy(a => a.Name).Select(a => new { a.Id, a.Name }).ToList(); ddlNoteType.Items.Clear(); ddlNoteType.Items.Add(new ListItem()); ddlNoteType.Items.AddRange(noteTypes.Select(a => new ListItem(a.Name, a.Id.ToString())).ToArray()); return(new System.Web.UI.Control[] { ddlNoteType }); }
/// <summary> /// Creates the child controls. /// </summary> /// <param name="parentControl"></param> /// <returns></returns> public override System.Web.UI.Control[] CreateChildControls( System.Web.UI.Control parentControl ) { RockDropDownList ddlNoteType = new RockDropDownList(); ddlNoteType.ID = parentControl.ID + "_ddlNoteType"; ddlNoteType.Label = "Note Type"; parentControl.Controls.Add( ddlNoteType ); var noteTypeService = new NoteTypeService( new RockContext() ); var noteTypes = noteTypeService.Queryable().OrderBy( a => a.Order ).ThenBy( a => a.Name ).Select( a => new { a.Id, a.Name } ).ToList(); ddlNoteType.Items.Clear(); ddlNoteType.Items.Add( new ListItem() ); ddlNoteType.Items.AddRange( noteTypes.Select( a => new ListItem( a.Name, a.Id.ToString() ) ).ToArray() ); return new System.Web.UI.Control[] { ddlNoteType }; }