WebApi Controller zwrócił wartość w projekcie Entity Framework 5 i MVC 4
Pracuję nad webapi, EF5, Windsor Castle w projekcie MVC 4 i mam pytanie ... Czy powinienem zwrócić Entity (lub DTO) w metodzie Get lub Czy powinienem zwrócić HttpResponseMessage? Jaki jest lepszy sposób i bardziej standardowy sposób, aby to zrobić?
Więc to jest to?
[System.Web.Http.HttpGet]
public HttpResponseMessage GetById(long id)
{
var branch = Uow.Branches.GetById(id);
if (branch != null)
{
Request.CreateResponse(HttpStatusCode.OK, branch);
}
throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotFound));
}
Albo to?
[System.Web.Http.HttpGet]
public Branch GetById(long id)
{
var branch = Uow.Branches.GetById(id);
if (branch != null) return branch ;
throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotFound));
}