我以前来过这里,但这次我比以前走得更远。我一直在关注本指南并完成了它所说的一切。如果我导航到http://localhost:61589/help我实际上看到了帮助页面,但只有介绍,没有描述。
在我的控制器中,我有这样的评论(总是这样):
/// <summary>
/// For all answer related endpoints
/// </summary>
[RoutePrefix("answers")]
public class AnswersController : ApiController
{
// Readonly properties
private readonly IUnitOfWork _unitOfWork;
private readonly AnswerService _service;
private readonly StateService _stateService;
/// <summary>
/// Default constructor
/// </summary>
public AnswersController()
{
// Map our properties
this._unitOfWork = new UnitOfWork<DatabaseContext>();
this._service = new AnswerService(this._unitOfWork);
this._stateService = new StateService(this._unitOfWork);
}
/// <summary>
/// Get a list of answers
/// </summary>
/// <returns></returns>
[HttpGet]
[Route("")]
public async Task<IHttpActionResult> GetAllAsync()
{
try
{
// Return all our answers
return Ok(await this._service.GetAllAsync("States.Filters"));
// If there is an error
}
catch (Exception ex)
{
// Return our error
return BadRequest(ex.Message.ToString());
}
}
/// <summary>
/// Get a answer by id
/// </summary>
/// <param name="id">The answer id</param>
/// <returns></returns>
[HttpGet]
[Route("")]
public async Task<IHttpActionResult> GetAsync(int id)
{
try
{
// Return all our answers
return Ok(await this._service.GetAsync(id, "States.Filters"));
// If there is an error
}
catch (Exception ex)
{
// Return our error
return BadRequest(ex.Message.ToString());
}
}
/// <summary>
/// Create a answer
/// </summary>
/// <param name="model">The answer model</param>
/// <returns></returns>
[HttpPost]
[Route("")]
public async Task<IHttpActionResult> CreateAsync(Answer model)
{
try
{
// Get our states
var all = await this._stateService.GetAllAsync("Filters");
var states = all.Where(m => model.States.Any(s => s.Id == m.Id)).ToList();
// Create our model
var answer = new Answer
{
Text = model.Text,
QuestionId = model.QuestionId,
Order = model.Order,
States = states
};
// Save our model
this._service.Create(answer);
// Save the database changes
await this._unitOfWork.SaveChangesAsync();
// Return our updated model
return Ok(answer);
// If there is an error
}
catch (Exception ex)
{
// Return our error
return BadRequest(ex.Message.ToString());
}
}
/// <summary>
/// Update a answer
/// </summary>
/// <param name="model">The answer model</param>
/// <returns></returns>
[HttpPut]
[Route("")]
public async Task<IHttpActionResult> UpdateAsync(Answer model)
{
try
{
// Create our model
var answer = new Answer
{
Id = model.Id,
QuestionId = model.QuestionId,
Order = model.Order,
Text = model.Text
};
// Save our model
this._service.Update(answer);
// Save the database changes
await this._unitOfWork.SaveChangesAsync();
// Return our updated model
return Ok(model);
// If there is an error
}
catch (Exception ex)
{
// Return our error
return BadRequest(ex.Message.ToString());
}
}
/// <summary>
/// Delete a answer
/// </summary>
/// <param name="id">The answer id</param>
/// <returns></returns>
[HttpDelete]
[Route("")]
public async Task<IHttpActionResult> DeleteAsync(int id)
{
try
{
// Get our model
var model = await this._service.GetAsync(id);
// Save our model
this._service.Remove(model);
// Save the database changes
await this._unitOfWork.SaveChangesAsync();
// Return Ok
return Ok();
// If there is an error
}
catch (Exception ex)
{
// Return our error
return BadRequest(ex.Message.ToString());
}
}
}
在生成的 XmlDocument.xml 我有这些成员:
<member name="T:Piiick.Api.Controllers.AnswersController">
<summary>
For all answer related endpoints
</summary>
</member>
<member name="M:Piiick.Api.Controllers.AnswersController.#ctor">
<summary>
Default constructor
</summary>
</member>
<member name="M:Piiick.Api.Controllers.AnswersController.GetAllAsync">
<summary>
Get a list of answers
</summary>
<returns></returns>
</member>
<member name="M:Piiick.Api.Controllers.AnswersController.GetAsync(System.Int32)">
<summary>
Get a answer by id
</summary>
<param name="id">The answer id</param>
<returns></returns>
</member>
<member name="M:Piiick.Api.Controllers.AnswersController.CreateAsync(Piiick.Data.Models.Answer)">
<summary>
Create a answer
</summary>
<param name="model">The answer model</param>
<returns></returns>
</member>
<member name="M:Piiick.Api.Controllers.AnswersController.UpdateAsync(Piiick.Data.Models.Answer)">
<summary>
Update a answer
</summary>
<param name="model">The answer model</param>
<returns></returns>
</member>
<member name="M:Piiick.Api.Controllers.AnswersController.DeleteAsync(System.Int32)">
<summary>
Delete a answer
</summary>
<param name="id">The answer id</param>
<returns></returns>
</member>
但是它们没有出现在实际的帮助页面上。有谁知道为什么会发生这种情况?