Пример #1
0
        public async Task <HttpResponseMessage> GetProducto(HttpRequestMessage request, int id)
        {
            return(await CreateHttpResponseAsync(request, async() =>
            {
                HttpResponseMessage response = null;
                string message = String.Empty;
                try
                {
                    var model = _productoService.GetProducto(id);
                    var kit = _productoService.GetProductosKit(id);
                    response = request.CreateResponse(HttpStatusCode.OK, new { producto = model, kit = kit });
                }
                catch (Exception ex)
                {
                    response = request.CreateResponse(HttpStatusCode.BadRequest,
                                                      new
                    {
                        error = "ERROR",
                        message = ex.Message
                    });
                }

                return await Task.FromResult(response);
            }));
        }