コード例 #1
0
        public async Task <JsonResult> updateStock(string ingredientes)
        {
            Models.CapaDatos misDatos  = null;
            bool             respuesta = false;

            using (misDatos = new Models.CapaDatos())
            {
                respuesta = await misDatos.updateStock(ingredientes);
            }
            return(Json(respuesta.ToString(), JsonRequestBehavior.AllowGet));
        }
コード例 #2
0
        public async Task <ActionResult> Index()
        {
            DataTable ingredientes = new DataTable();
            DataTable platillos    = new DataTable();

            Models.CapaDatos misDatos = null;

            using (misDatos = new Models.CapaDatos())
            {
                ingredientes = await misDatos.getIngredientes();

                platillos = await misDatos.getPlatillos();
            }
            ViewBag.Ingredientes = ingredientes;
            ViewBag.Platillos    = platillos;

            return(View());
        }
コード例 #3
0
        public async Task <ActionResult <string> > Get(int id)
        {
            try
            {
                DataTable        platillos = new DataTable();
                Models.CapaDatos misDatos  = new Models.CapaDatos(configuration);
                var grupo   = "grupouniacc";
                var headers = Request.Headers;
                Microsoft.Extensions.Primitives.StringValues headerValues;
                headers.TryGetValue("tokenBearer", out headerValues);
                var tokenBearer = headerValues.First();
                headers.TryGetValue("username", out headerValues);
                var    username      = headerValues.First();
                string tokenUsername = misDatos.ValidateToken(tokenBearer);

                if (tokenUsername.Equals(grupo))
                {
                    using (misDatos = new Models.CapaDatos(configuration))
                    {
                        platillos = await misDatos.getPlatilloPorId(id);
                    }
                    string JSONString = string.Empty;
                    JSONString = JsonConvert.SerializeObject(platillos);
                    return(JSONString);
                }
                else
                {
                    throw new Exception();
                }
            }
            catch (Exception)
            {
                return(StatusCode(500, "Oooops, Acceso No Autorizado!!!"));
                //return Unauthorized();
            }
        }