コード例 #1
0
        /// <summary>
        /// Create data in database
        /// </summary>
        /// <param name="trainingJournalDay">Data</param>
        /// <returns>insert data</returns>
        public TrainingDay Create(TrainingDay trainingJournalDay)
        {
            if (trainingJournalDay == null || string.IsNullOrWhiteSpace(trainingJournalDay.UserId) ||
                trainingJournalDay.Year == 0 || trainingJournalDay.WeekOfYear == 0 ||
                trainingJournalDay.DayOfWeek < 0 || trainingJournalDay.DayOfWeek > 6 || trainingJournalDay.TrainingDayId == 0)
                return null;

            var row = new TrainingDayRow();
            TrainingDayTransformer.ToRow(trainingJournalDay, row);
            _dbContext.TrainingDay.Add(row);
            _dbContext.SaveChanges();
            return TrainingDayTransformer.ToBean(row);
        }
コード例 #2
0
        public static void ToRow(TrainingDay bean, TrainingDayRow row)
        {
            if (bean == null)
                return;

            row.UserId = bean.UserId;
            row.Year = bean.Year;
            row.WeekOfYear = bean.WeekOfYear;
            row.DayOfWeek = bean.DayOfWeek;
            row.TrainingDayId = bean.TrainingDayId;
            row.BeginHour = DbUtils.DateToUtc(bean.BeginHour);
            row.EndHour = DbUtils.DateToUtc(bean.EndHour);
            row.ModificationDate = DbUtils.DateToUtc(Utils.DateTimeWithoutMs); // Set modificationDate
        }
コード例 #3
0
        internal static TrainingDay ToBean(TrainingDayRow row)
        {
            if (row == null)
                return null;

            var bean = new TrainingDay();
            bean.UserId = row.UserId;
            bean.Year = row.Year;
            bean.WeekOfYear = row.WeekOfYear;
            bean.DayOfWeek = row.DayOfWeek;
            bean.TrainingDayId = row.TrainingDayId;
            bean.BeginHour = DbUtils.DbDateToUtc(row.BeginHour);
            bean.EndHour = DbUtils.DbDateToUtc(row.EndHour);
            bean.ModificationDate = DbUtils.DbDateToUtc(row.ModificationDate);
            return bean;
        }