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()); }
public async Task <ActionResult <string> > Get() { 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.getPlatillos(); } 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(); } }