31.10.2014 Views

Developer's Guide - EPiServer World

Developer's Guide - EPiServer World

Developer's Guide - EPiServer World

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

76 | Developer’s <strong>Guide</strong> <strong>EPiServer</strong> Community 3.1<br />

2.18.8 Approve an Answer<br />

Before publishing the answer to the public, it might be necessary to review the answer to approve it. This section<br />

provides information on how to approve an answer.<br />

Import Necessary Namespaces<br />

First, import the necessary namespaces that will be used to answer a question. The namespace<br />

StarCommunity.Modules.Expert is described by clicking on its name. Make sure you add the assembly as a reference,<br />

mentioned in section 1.1.1.<br />

using StarCommunity.Modules.Expert;<br />

Approve an Answer<br />

To approve an answer, the Answer object has to be retrieved from the database. Approving an answer means setting<br />

the Status property to AnswerStatus.Approved. When the Answer object is changed, it has to be committed to<br />

database using the UpdateAnswer method of the ExpertHandler class.<br />

// Get the answer from the database<br />

Answer answer = (Answer)ExpertHandler.GetAnswer(396).Clone();<br />

// Update answer status<br />

answer.Status = AnswerStatus.Approved;<br />

// Update answer in the database<br />

answer = ExpertHandler.UpdateAnswer(answer);<br />

2.18.9 Get Questions Assigned to an Expert<br />

Normally, when an expert logs into the site, you want to show the questions assigned. This section explains how to do<br />

it in detail.<br />

Import Necessary Namespaces<br />

First, import the necessary namespaces that will be used to answer a question. The namespace<br />

StarCommunity.Modules.Expert is described by clicking on its name. Make sure you add the assembly as a reference,<br />

mentioned in section 1.1.1.<br />

using StarCommunity.Modules.Expert;<br />

© <strong>EPiServer</strong> AB

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!