コード例 #1
0
        public IHttpActionResult ProductosPorUsuario(int id)
        {
            ListarProductoResponse objresponse = new ListarProductoResponse();

            objresponse.status = new ProcesoResponse();
            objresponse.Hits   = new List <Dominio.Producto>();

            try
            {
                var restaurante = BD.t_restaurante.Where(z => z.usua_id == id).FirstOrDefault();


                if (restaurante != null)
                {
                    var query = BD.t_producto.Where(x => x.rest_ruc == restaurante.rest_ruc);

                    foreach (var item in query)
                    {
                        objresponse.Hits.Add(new Dominio.Producto()
                        {
                            prod_descrip = item.prod_descrip,
                            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.totalregistros = objresponse.Hits.Count();
                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));
        }
コード例 #2
0
        public ListarProductoResponse ListarProductoPorUsuario(long CodigoUsuario)
        {
            ListarProductoResponse response = new ListarProductoResponse();

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

            return(response);
        }
コード例 #3
0
        public IHttpActionResult Get()
        {
            ListarProductoResponse objresponse = new ListarProductoResponse();

            objresponse.status = new ProcesoResponse();
            objresponse.Hits   = new List <Dominio.Producto>();

            try
            {
                var query = BD.t_producto.ToList();

                foreach (var item in query)
                {
                    objresponse.Hits.Add(new Dominio.Producto()
                    {
                        prod_descrip = item.prod_descrip,
                        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.totalregistros = query.Count();
                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));
        }