public Show ( string message, ModalAlertType alertType ) : void | ||
message | string | The message. |
alertType | ModalAlertType | Type of the message. |
리턴 | void |
/// <summary> /// Deletes the note. /// </summary> /// <param name="noteId">The note identifier.</param> private void DeleteNote(int?noteId) { var rockPage = this.Page as RockPage; if (rockPage != null) { var currentPerson = rockPage.CurrentPerson; var rockContext = new RockContext(); var service = new NoteService(rockContext); Note note = null; if (noteId.HasValue) { note = service.Get(noteId.Value); if (note != null && note.IsAuthorized(Authorization.EDIT, currentPerson)) { string errorMessage; if (service.CanDeleteChildNotes(note, currentPerson, out errorMessage) && service.CanDelete(note, out errorMessage)) { service.Delete(note, true); rockContext.SaveChanges(); } else { _mdDeleteWarning.Show(errorMessage, ModalAlertType.Information); return; } } } } }
/// <summary> /// Handles the Click event of the lbSaveNote 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 lbSaveNote_Click(object sender, EventArgs e) { if (_ddlNoteType.Visible) { NoteTypeId = _ddlNoteType.SelectedValueAsInt() ?? 0; } var rockPage = this.Page as RockPage; if (rockPage != null && NoteTypeId.HasValue) { var currentPerson = rockPage.CurrentPerson; var rockContext = new RockContext(); var service = new NoteService(rockContext); Note note = null; if (NoteId.HasValue) { note = service.Get(NoteId.Value); } if (note == null) { note = new Note(); note.IsSystem = false; note.EntityId = EntityId; note.ParentNoteId = _hfParentNoteId.Value.AsIntegerOrNull(); service.Add(note); } else { if (!note.IsAuthorized(Authorization.EDIT, currentPerson)) { // if somehow a person is trying to edit a note that they aren't authorized to edit, don't update the note _mdEditWarning.Show("Not authorized to edit note", ModalAlertType.Warning); return; } } if (_hfHasUnselectableNoteType.Value.AsBoolean() && note.NoteTypeId > 0 && note.Id > 0) { // a note type with an unselectable notetype was edited, so just keep the notetype that is had before } else { note.NoteTypeId = NoteTypeId.Value; } string personalNoteCaption = "You - Personal Note"; if (string.IsNullOrWhiteSpace(note.Caption)) { note.Caption = IsPrivate ? personalNoteCaption : string.Empty; } else { // if the note still has the personalNoteCaption, but was changed to have IsPrivateNote to false, change the caption to empty string if (note.Caption == personalNoteCaption && !IsPrivate) { note.Caption = string.Empty; } } note.Text = Text; note.IsAlert = IsAlert; note.IsPrivateNote = IsPrivate; if (NoteOptions.ShowCreateDateInput) { note.CreatedDateTime = _dtCreateDate.SelectedDateTime; } note.EditedByPersonAliasId = currentPerson?.PrimaryAliasId; note.EditedDateTime = RockDateTime.Now; note.NoteUrl = this.RockBlock()?.CurrentPageReference?.BuildUrl(); var noteType = NoteTypeCache.Get(note.NoteTypeId); if (noteType.RequiresApprovals) { if (note.IsAuthorized(Authorization.APPROVE, currentPerson)) { note.ApprovalStatus = NoteApprovalStatus.Approved; note.ApprovedByPersonAliasId = currentPerson?.PrimaryAliasId; note.ApprovedDateTime = RockDateTime.Now; } else { note.ApprovalStatus = NoteApprovalStatus.PendingApproval; } } else { note.ApprovalStatus = NoteApprovalStatus.Approved; } rockContext.SaveChanges(); if (SaveButtonClick != null) { SaveButtonClick(this, new NoteEventArgs(note.Id)); } } }