コード例 #1
0
        public bool Add(DietLogDTO entity)
        {
            DietLog dietlog = new DietLog();

            dietlog.MemberID     = entity.MemberID;
            dietlog.TimeOfDayID  = entity.TimeOfDayID;
            dietlog.MealOptionID = entity.MealOptionID;
            dietlog.EditTime     = entity.EditTime;
            dietlog.Portion      = entity.Portion;
            dietlog.Date         = entity.Date;
            return(dao.Add(dietlog));
        }
コード例 #2
0
        internal DietLogDTO GetDietLog(int dietLogID)
        {
            try
            {
                DietLog theDLog = db.DietLogs.FirstOrDefault(dl => dl.ID == dietLogID);

                DietLogDTO dto = new DietLogDTO(theDLog);
                return(dto);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #3
0
        private void btnAddToTempList_Click(object sender, EventArgs e)
        {
            if (theMeal == null)
            {
                return;
            }
            TimeOfDayDTO selectedTOD = this.cBoxTimesOfDay.SelectedItem as TimeOfDayDTO;

            if (selectedTOD == null || this.tBoxTotalCal.Text == "")
            {
                MessageBox.Show("請確認時段及份量");
                return;
            }
            //double gainCalories = dBll.GetMealConsumedCalories(theMeal.Calories, thePortion);

            DietLogDTO dL = new DietLogDTO();

            dL.MemberID     = StaticUser.UserID;
            dL.MealOptionID = theMeal.ID;
            dL.Portion      = thePortion;
            dL.TimeOfDayID  = selectedTOD.ID;
            dL.Date         = this.dateTimePicker1.Value; //
            dL.EditTime     = DateTime.Now;
            //-------------------------
            dL.圖片       = theMeal.Image;
            dL.日期       = dL.Date;
            dL.時段       = selectedTOD.Name;
            dL.餐點名稱     = theMeal.Name;
            dL.每100克卡路里 = (int)theMeal.Calories;
            dL.份量       = dL.Portion;
            dL.總卡路里     = (int)(dL.每100克卡路里 * dL.份量);
            mealList.Add(dL);

            this.bS_AddedMeals.DataSource = mealList.ToList().OrderByDescending(dl => dl.Date).ThenBy(dl => dl.TimeOfDayID);

            ShowReqdColumns();
            this.tBoxTotalCal.Text = "";
        }