1
public async Task<HttpResponseMessage> getOne(HttpRequestMessage request, int id)
{
return CreateResponse(async() =>
{
var category = await _unitOfWork.Categories.GetSingleAsync(id);
var categoryVm = Mapper.Map<Category, CategoryViewModel>(category);
HttpResponseMessage response = request.CreateResponse<CategoryViewModel>(HttpStatusCode.OK, categoryVm);
return response;
});
}
protected Task<IHttpActionResult> CreateResponse(Func<IHttpActionResult, Task> function)
{
IHttpActionResult response = null;
try
{
response = function.Invoke();
}
}