public GetConversationEditorFormDataResponse GetConversationEditorFormData(
            GetConversationEditorFormDataRequest request)
        {
            var staffAssembler = new StaffAssembler();
            var groupAssembler = new StaffGroupAssembler();
            var response       = new GetConversationEditorFormDataResponse(
                CollectionUtils.Map(
                    this.CurrentUserStaff.ActiveGroups,                         // only active staff groups should be choices
                    (StaffGroup sg) => groupAssembler.CreateSummary(sg)));

            if (request.RecipientStaffIDs != null && request.RecipientStaffIDs.Count > 0)
            {
                var criteria = new StaffSearchCriteria();
                criteria.Id.In(request.RecipientStaffIDs);
                response.RecipientStaffs = CollectionUtils.Map(
                    PersistenceContext.GetBroker <IStaffBroker>().Find(criteria),
                    (Staff s) => staffAssembler.CreateStaffSummary(s, PersistenceContext));
            }

            if (request.RecipientStaffGroupNames != null && request.RecipientStaffGroupNames.Count > 0)
            {
                var criteria = new StaffGroupSearchCriteria();
                criteria.Name.In(request.RecipientStaffGroupNames);
                response.RecipientStaffGroups = CollectionUtils.Map(
                    PersistenceContext.GetBroker <IStaffGroupBroker>().Find(criteria),
                    (StaffGroup sg) => groupAssembler.CreateSummary(sg));
            }

            return(response);
        }
        /// <summary>
        /// Called by the host to initialize the application component.
        /// </summary>
        public override void Start()
        {
            // init lookup handlers
            _cannedTextLookupHandler = new CannedTextLookupHandler(this.Host.DesktopWindow);

            // init recip table here, and not in constructor, because it relies on Host being set
            _recipients = new RecipientTable(this);

            // if exactly 1 template choice, then it is selected
            _selectedTemplate = _templateChoices.Count == 1 ? _templateChoices[0] : null;

            // create soft keys
            UpdateSoftKeys();

            // load the existing conversation, plus editor form data
            GetConversationEditorFormDataResponse formDataResponse = null;

            Platform.GetService <IOrderNoteService>(
                service =>
            {
                var formDataRequest = new GetConversationEditorFormDataRequest(
                    _selectedTemplate != null ? _selectedTemplate.GetStaffRecipients() : new List <string>(),
                    _selectedTemplate != null ? _selectedTemplate.GetGroupRecipients() : new List <string>());
                formDataResponse = service.GetConversationEditorFormData(formDataRequest);

                var request  = new GetConversationRequest(_orderRef, new List <string>(_orderNoteCategories), false);
                var response = service.GetConversation(request);

                _orderRef   = response.OrderRef;
                _orderNotes = response.OrderNotes;
            });


            // init on-behalf of choices
            _onBehalfOfChoices = formDataResponse.OnBehalfOfGroupChoices;
            _onBehalfOfChoices.Insert(0, _emptyStaffGroup);

            // initialize from template (which may be null)
            InitializeFromTemplate(_selectedTemplate, formDataResponse.RecipientStaffs, formDataResponse.RecipientStaffGroups);

            // build the action model
            _recipientsActionModel = new CrudActionModel(true, false, true, new ResourceResolver(this.GetType(), true));
            _recipientsActionModel.Add.SetClickHandler(AddRecipient);
            _recipientsActionModel.Delete.SetClickHandler(DeleteRecipient);

            // init conversation view component
            _orderNoteViewComponent = new OrderNoteViewComponent(_orderNotes);
            _orderNoteViewComponent.CheckedItemsChanged += delegate { NotifyPropertyChanged("CompleteButtonLabel"); };
            _orderNotesComponentHost = new ChildComponentHost(this.Host, _orderNoteViewComponent);
            _orderNotesComponentHost.StartComponent();

            base.Start();
        }