示例#1
0
        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));
        }
示例#2
0
        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));
        }
示例#3
0
        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)));
 }