コード例 #1
0
ファイル: slump.cs プロジェクト: ahakille/Matslumpiator
        public List <Receptmodels> Oldslumps(int user_id, DateTime date, DateTime dateto)
        {
            slump               Slump = new slump();
            postgres            m     = new postgres();
            List <Receptmodels> mt    = new List <Receptmodels>();
            DataTable           dt    = new DataTable();

            dt = m.SqlQuery("SELECT foodlist.date_now,foodlist.recept_id,recept.name FROM public.foodlist join public.recept on foodlist.recept_id = recept.id_recept Where foodlist.user_id = @id_user AND date_now BETWEEN @datefrom AND @dateto ORDER BY date_now DESC; ", postgres.list = new List <NpgsqlParameter>()
            {
                new NpgsqlParameter("@id_user", user_id),
                new NpgsqlParameter("@dateto", dateto),
                new NpgsqlParameter("@datefrom", date)
            });
            foreach (DataRow dr in dt.Rows)
            {
                Receptmodels r = new Receptmodels();
                r.Id          = (int)dr["recept_id"];
                r.Name        = dr["name"].ToString();
                r.Date        = (DateTime)dr["date_now"];
                r.Weeknumbers = GetIso8601WeekOfYear(r.Date).ToString();


                mt.Add(r);
            }



            return(mt);
        }
コード例 #2
0
        public List <UsersEditViewmodel> Getuser(int id, string sql)
        {
            postgres  m  = new postgres();
            DataTable dt = new DataTable();
            List <UsersEditViewmodel> mt = new List <UsersEditViewmodel>();

            dt = m.SqlQuery(sql, postgres.list = new List <NpgsqlParameter>()
            {
                new NpgsqlParameter("@id", id)
            });
            foreach (DataRow dr in dt.Rows)
            {
                UsersEditViewmodel r = new UsersEditViewmodel();
                r.User_id    = (int)dr["user_id"];
                r.User       = dr["username"].ToString();
                r.email      = (string)dr["email"];
                r.First_name = (string)dr["fname"];
                r.Last_name  = (string)dr["last_name"];
                r.CronoDay   = (int)dr["day_of_slumpcron"];



                mt.Add(r);
            }

            return(mt);
        }
コード例 #3
0
        public List <Users> GetuserAsAdmin(int id, string sql)
        {
            postgres     m  = new postgres();
            DataTable    dt = new DataTable();
            List <Users> mt = new List <Users>();

            dt = m.SqlQuery(sql, postgres.list = new List <NpgsqlParameter>()
            {
                new NpgsqlParameter("@id", id)
            });
            foreach (DataRow dr in dt.Rows)
            {
                Users r = new Users();
                r.User_id     = (int)dr["user_id"];
                r.User        = dr["username"].ToString();
                r.email       = (string)dr["email"];
                r.active      = (bool)dr["acc_active"];
                r.Roles_id    = (int)dr["roles_id"];
                r.Last_login  = (DateTime)dr["last_login"];
                r.Last_name   = (string)dr["last_name"];
                r.First_name  = (string)dr["fname"];
                r.Settings_id = (int)dr["settings_id"];


                mt.Add(r);
            }

            return(mt);
        }
コード例 #4
0
ファイル: slump.cs プロジェクト: ahakille/Matslumpiator
        public bool Checkslump(DateTime date, int user_id)
        {
            postgres  m     = new postgres();
            bool      check = false;
            DataTable dt    = new DataTable();

            dt = m.SqlQuery("SELECT EXISTS(SELECT foodlist.date_now,foodlist.recept_id FROM public.foodlist Where foodlist.user_id = @user_id AND date_now = @date_now)", postgres.list = new List <NpgsqlParameter>()
            {
                new NpgsqlParameter("@date_now", date),
                new NpgsqlParameter("@user_id", user_id)
            });
            foreach (DataRow dr in dt.Rows)
            {
                check = (bool)dr["exists"];
            }
            return(check);
        }
コード例 #5
0
        public List <keyword> getMatTyp(string psql)
        {
            postgres       m  = new postgres();
            DataTable      dt = new DataTable();
            List <keyword> mt = new List <keyword>();

            dt = m.SqlQuery(psql, postgres.list = new List <NpgsqlParameter>()
            {
                new NpgsqlParameter("@idag", DateTime.Now)
            });
            foreach (DataRow dr in dt.Rows)
            {
                keyword t = new keyword();
                t.id   = Convert.ToInt16(dr["pk_id"].ToString());
                t.name = dr["name"].ToString();
                mt.Add(t);
            }
            return(mt);
        }