Exemplo n.º 1
0
        // When the user clicks on a customer in their customer queue, the
        // CustomerQueueController calls us to tell us to start working with
        // the customer.
        //
        // Editing a customer is self-contained in a work item (the CustomerWorkItem)
        // so we end up with one CustomerWorkItem contained in ourselves for
        // each customer that is being edited.
        public void WorkWithCustomer(Customer customer)
        {
            // Construct a key to register the work item in ourselves
            string key = string.Format("Customer#{0}", customer.ID);

            // Have we already made the work item for this customer?
            // If so, return the existing one.
            CustomerWorkItem workItem = this.Items.Get <CustomerWorkItem>(key);

            if (workItem == null)
            {
                workItem = WorkItems.AddNew <CustomerWorkItem>(key);
                //Set ID before setting state.  State will be cleared if a new id is set.
                workItem.ID = key;
                workItem.State[StateConstants.CUSTOMER] = customer;

                // Ask the persistence service if we have a saved version of
                // this work item. If so, load it from persistence.
                if (PersistenceService != null && PersistenceService.Contains(workItem.ID))
                {
                    workItem.Load();
                }
            }

            workItem.Show(contentWorkspace);
        }