Пример #1
0
        /// <summary>
        /// Create data in database
        /// </summary>
        /// <param name="muscle">Data</param>
        /// <returns>insert data</returns>
        public Muscle Create(Muscle muscle)
        {
            if (muscle == null)
                return null;

            if (muscle.Id == 0)
            {
                var key = new MuscleKey();
                var sequencerManager = new SequencerManager();
                do
                {
                    key.Id = sequencerManager.GetNextValue(_dbContext, 4, "muscle");
                }
                while (Get(key) != null); // Test Record exist
                muscle.Id = key.Id;
            }

            if (muscle.Id == 0)
                return null;

            var row = new MuscleRow();
            MuscleTransformer.ToRow(muscle, row);
            _dbContext.Muscle.Add(row);
            _dbContext.SaveChanges();

            return MuscleTransformer.ToBean(row);
        }
Пример #2
0
        public static void ToRow(Muscle bean, MuscleRow row)
        {
            if (bean == null)
                return;

            row.Id = bean.Id;
            row.MuscularGroupId = bean.MuscularGroupId;
        }
Пример #3
0
        internal static Muscle ToBean(MuscleRow row)
        {
            if (row == null)
                return null;

            var bean = new Muscle();
            bean.Id = row.Id;
            bean.MuscularGroupId = row.MuscularGroupId;
            return bean;
        }