Exemple #1
0
        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);
        }
Exemple #2
0
        public List <slump> Weeknumbers(List <Receptmodels> lista)
        {
            List <slump> list  = new List <slump>();
            string       check = "";

            foreach (var item in lista)
            {
                if (check != item.Weeknumbers)
                {
                    slump sl = new slump();
                    sl.Weeknumber = item.Weeknumbers;
                    list.Add(sl);
                    check = item.Weeknumbers;
                }
            }
            return(list);
        }