Example #1
0
 public void AddMenu(DailyMenu menu)
 {
     foreach (Food food in menu.foods)
     {
         ProcedureManager.Prepare(procedureName)
         .AddValue(ProcedureFields.ProcessType, ProcessType.Insert)
         .AddValue(ProcedureFields.Date, menu.date)
         .AddValue(ProcedureFields.Name, food.name)
         .AddValue(ProcedureFields.Calorie, food.calorie)
         .AddValue(ProcedureFields.Contents, food.contents)
         .AddValue(ProcedureFields.ImageSrc, food.imageSrc)
         .Execute();
     }
 }
Example #2
0
        public List <DailyMenu> GetMenuList()
        {
            List <DailyMenu> menuList = new List <DailyMenu>();

            DataTable dataTable = ProcedureManager.Prepare(procedureName)
                                  .AddValue(ProcedureFields.ProcessType, ProcessType.Select)
                                  .AddValue(ProcedureFields.Date, DateTime.Now.AddDays(-20))
                                  .ExecuteAndReturnValue();

            DailyMenu currentMenu = null;

            for (int i = 0; i < dataTable.Rows.Count; i++)
            {
                DataRow row  = dataTable.Rows[i];
                string  date = ((DateTime)row[0]).ToString("yyyy-MM-dd");

                if (currentMenu == null)
                {
                    currentMenu      = new DailyMenu();
                    currentMenu.date = date;
                }
                else if (currentMenu.date != date)
                {
                    menuList.Add(currentMenu);
                    currentMenu      = new DailyMenu();
                    currentMenu.date = date;
                }

                if (currentMenu.foods == null)
                {
                    currentMenu.foods = new List <Food>();
                }

                currentMenu.foods.Add(new Food()
                {
                    name     = (string)row[1],
                    calorie  = (int)row[2],
                    contents = (string)row[3],
                    imageSrc = (string)row[4]
                });
            }

            return(menuList);
        }
Example #3
0
 public int MenuCount()
 {
     return((int)ProcedureManager.Prepare(procedureName)
            .AddValue(ProcedureFields.ProcessType, ProcessType.Count)
            .ExecuteAndReturnValue().Rows[0][0]);
 }
Example #4
0
 public void ClearMenuList()
 {
     ProcedureManager.Prepare(procedureName)
     .AddValue(ProcedureFields.ProcessType, ProcessType.Truncate)
     .Execute();
 }