Example #1
0
        public void OnGet()
        {
            string id = Request.Query["id"];

            if (id != null)
            {
                //Obtengo el directorio para el archivo json
                var    service     = HttpContext.RequestServices.GetService(typeof(Microsoft.AspNetCore.Hosting.IHostingEnvironment)) as Microsoft.AspNetCore.Hosting.IHostingEnvironment;
                string folderName  = "json/";
                string webRootPath = service.WebRootPath;
                string Path        = System.IO.Path.Combine(webRootPath, folderName);

                // Cargo el json en la entidad
                menuDta sf = JsonConvert.DeserializeObject <menuDta>(System.IO.File.ReadAllText(Path + @"/menu_" + id + ".json"));
            }
        }
Example #2
0
        // Este método lo uso solo la primera vez para poder crear un objeto del tipo json que luego voy a desserializar
        private void crearJsonMenu()
        {
            menuDta mnu = new menuDta();

            mnu.Nombre = "Cena";
            mnu.id     = "1";
            mnu.types  = new List <menuType>();

            menuType type = new menuType();

            type.titulo_es  = "Platos";
            type.hora_desde = "10:00";
            type.hora_hasta = "18:00";
            type.items      = new List <menuItem>();

            menuItem item = new menuItem();

            item.titulo_es = "Papas Fritas";
            item.titulo_en = "Chips";
            item.titulo_pt = "Patatas Fritas";
            type.items.Add(item);
            menuItem item2 = new menuItem();

            item2.titulo_es = "Lomo";
            item2.titulo_en = "Meat Beef";
            item2.titulo_pt = "Rostizado";

            type.items.Add(item2);
            mnu.types.Add(type);

            //Obtengo el directorio para el archivo
            var    service     = HttpContext.RequestServices.GetService(typeof(Microsoft.AspNetCore.Hosting.IHostingEnvironment)) as Microsoft.AspNetCore.Hosting.IHostingEnvironment;
            string folderName  = "json/";
            string webRootPath = service.WebRootPath;
            string newPath     = Path.Combine(webRootPath, folderName);

            //Serializo el objeto a json
            string objeto = JsonConvert.SerializeObject(mnu);

            //Escribo en disco el archivo
            System.IO.File.WriteAllText(newPath + @"/menu_" + mnu.id + ".json", objeto);
        }
Example #3
0
        public void OnGet()
        {
            pedidos = "";
            string id              = Request.Query["id"];
            string menu            = Request.Query["m"];
            string side            = Request.Query["s"];
            string pedido_reciente = "";

            try
            {
                if (id != null && menu != null && side != null)
                {
                    bool reciente = memoryCache.TryGetValue("mesa_" + id, out pedido_reciente);

                    if (!existePedido(id, side))
                    {
                        //Obtengo el directorio para el archivo json
                        var    service     = HttpContext.RequestServices.GetService(typeof(Microsoft.AspNetCore.Hosting.IHostingEnvironment)) as Microsoft.AspNetCore.Hosting.IHostingEnvironment;
                        string folderName  = "json/";
                        string webRootPath = service.WebRootPath;
                        string Path        = System.IO.Path.Combine(webRootPath, folderName);

                        // Cargo el json en la entidad
                        menuDta md = JsonConvert.DeserializeObject <menuDta>(System.IO.File.ReadAllText(Path + @"/menu_" + menu + ".json"));
                        types = md.types;
                    }
                    else
                    {
                        string pedido = @"<div class='alert alert-success' role='alert'> 
                        <h4>Ups!!!</h4>
                        <p class='text-success'>Queres hacer algún cambio en tu pedido? informa al asistente de la sala (estas en la mesa Nro: " + id + ") </p>";
                        pedido += "<b>";
                        pedido += pedido_reciente;
                        pedido += @"</b> 
                        <h6>Ya estamos preparando todo para que pronto este en tu mesa</h6></span>
                        </div>";

                        pedidos = pedido;
                    }
                }
                else
                {
                    string mensaje =
                        @"<div class='alert alert-danger' role='alert'> 
                        <h4>Ups!!! </h4>
                    </div>
                    <ul>
                        <li>Escanee el código QR que se encuentra en su mesa</li>
                        <li>Seleccione del menu lo que quiera ordenar</li>
                        <li>Presione en enviar para ingresar su pedido</li>
                        <li>Una vez finalizado, confirme con el personal de la sala que todo esta ok</li>
                    </ul>
                    <p>
                        Sera entregado en su mesa dentro de los 40 minutos desde la confirmacion de la orden.
                    </p>
                    ";
                    pedidos = mensaje;
                }
            }
            catch (Exception ex)
            {
                string mensaje =
                    @"<div class='alert alert-danger' role='alert'> 
                        <h4>Error </h4>
                    </div>
                    <p>" + ex.Message + "</p>";

                pedidos = mensaje;
            }
        }