public HttpResponseMessage Details(HttpRequestMessage request, string id) { Func <HttpResponseMessage> func = () => { HttpResponseMessage response = null; Function functionDb = _functionService.Get(id); FunctionViewModel functionVm = Mapper.Map <FunctionViewModel>(functionDb); response = request.CreateResponse(HttpStatusCode.OK, functionVm); return(response); }; return(CreateHttpResponse(request, func)); }
public HttpResponseMessage Details(HttpRequestMessage request, string id) { if (string.IsNullOrEmpty(id)) { return(request.CreateErrorResponse(HttpStatusCode.BadRequest, nameof(id) + " không có giá trị.")); } var function = _functionService.Get(id); if (function == null) { return(request.CreateErrorResponse(HttpStatusCode.NoContent, "No data")); } var modelVm = Mapper.Map <Function, FunctionViewModel>(function); return(request.CreateResponse(HttpStatusCode.OK, modelVm)); }
public HttpResponseMessage GetById(HttpRequestMessage request, string id) { return(CreateHttpResponse(request, () => { if (string.IsNullOrEmpty(id)) { return request.CreateErrorResponse(HttpStatusCode.BadRequest, nameof(id) + " không có giá trị"); } var model = _functionService.Get(id); var responseData = Mapper.Map <Function, FunctionViewModel>(model); var response = request.CreateResponse(HttpStatusCode.OK, responseData); return response; })); }
public IActionResult Detail(string id) { return(new OkObjectResult(_functionService.Get(id))); }