Beispiel #1
0
    public List <MenuDes> GetMenuDes(SQLiteConnection connection, List <string> menuList, string lang)
    {
        List <MenuDes> xx = new List <MenuDes>();

        foreach (string m in menuList)
        {
            MenuDes x = GetMenuDesSql(connection, m, lang);
            xx.Add(x);
        }
        return(xx);
    }
        public ActionResult Desayuno(List <AgregarMenu> agregarMenus)
        {
            if (Session["UserName"] != null)
            {
                int idlocal  = 0;
                int dialocal = 0;
                int flag     = 0;

                foreach (var comida in agregarMenus)
                {
                    if (flag == 0)
                    {
                        var query = (from md in dbContext.MenuDes
                                     where md.MenuSemanalID == comida.menuID && md.DiaID == comida.diaID && md.TiempoID == comida.tiempoID
                                     select md).ToList();


                        if (query.Count > 0)
                        {
                            foreach (var q in query)
                            {
                                dbContext.MenuDes.Remove(q);
                                dbContext.SaveChanges();
                            }
                        }

                        flag = 1;
                    }

                    idlocal  = comida.menuID;
                    dialocal = comida.diaID;

                    if (comida.isSelected == true)
                    {
                        MenuDes menuDes = new MenuDes();
                        menuDes.MenuSemanalID = comida.menuID;
                        menuDes.DiaID         = comida.diaID;
                        menuDes.TiempoID      = comida.tiempoID;
                        menuDes.ComidaID      = comida.ID;

                        dbContext.MenuDes.Add(menuDes);
                        dbContext.SaveChanges();
                    }
                }
                return(RedirectToAction("Snack", "AgregarMenu", new { id = idlocal, dia = dialocal }));
            }

            else
            {
                //Si no se inicio sesion no se puede acceder a esta pagina
                return(RedirectToAction("Login", "Login"));
            }
        }
Beispiel #3
0
    MenuDes GetMenuDesSql(SQLiteConnection connection, string m, string lang)
    {
        MenuDes x   = new MenuDes();
        string  sql = string.Format(@"SELECT title, diet, energy FROM menues WHERE id = '{0}'", m);

        using (SQLiteCommand command = new SQLiteCommand(sql, connection)) {
            using (SQLiteDataReader reader = command.ExecuteReader()) {
                while (reader.Read())
                {
                    x.title  = reader.GetValue(0) == DBNull.Value ? "" : reader.GetString(0);
                    x.diet   = reader.GetValue(1) == DBNull.Value ? "" : t.Tran(reader.GetString(1), lang);
                    x.energy = reader.GetValue(2) == DBNull.Value ? 0 : Convert.ToDouble(reader.GetString(2));
                }
            }
        }
        return(x);
    }