예제 #1
0
        public LeerProductoResponse LeerProducto(long id)
        {
            LeerProductoResponse response = new LeerProductoResponse();

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(ServicioCommon.Parametros.URLServicio);
                var responseTask = client.GetAsync("api/Producto/" + id);
                responseTask.Wait();
                var result = responseTask.Result;
                if (result.IsSuccessStatusCode)
                {
                    var colaboradorResponse = result.Content.ReadAsStringAsync().Result;
                    response = JsonConvert.DeserializeObject <LeerProductoResponse>(colaboradorResponse);
                }
            }

            return(response);
        }
        public IHttpActionResult Get(int id)
        {
            LeerProductoResponse objresponse = new LeerProductoResponse();

            objresponse.status = new ProcesoResponse();
            objresponse.Hit    = new Dominio.Producto();

            try
            {
                var item = BD.t_producto.Where(x => x.prod_id == id).FirstOrDefault();


                objresponse.Hit = new Dominio.Producto()
                {
                    prod_descrip = item.prod_nombre,
                    prod_nombre  = item.prod_nombre,
                    prod_id      = item.prod_id,
                    prod_precio  = item.prod_precio,
                    rest_ruc     = item.prod_nombre,
                    tico_descrip = item.prod_nombre,
                    tico_id      = item.tico_id
                };



                objresponse.status.estado  = 0;
                objresponse.status.mensaje = "Info de menu";
            }
            catch (Exception err)
            {
                objresponse.status.estado  = -1;
                objresponse.status.mensaje = err.Message;
                throw err;
            }

            return(Ok(objresponse));
        }