/// <summary>
        /// Create data in database
        /// </summary>
        /// <param name="bodyExercise">Data</param>
        /// <returns>insert data</returns>
        public BodyExercise Create(BodyExercise bodyExercise)
        {
            if (bodyExercise == null)
            {
                return(null);
            }

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

            if (bodyExercise.Id == 0)
            {
                return(null);
            }

            var bodyExerciseRow = new BodyExerciseRow();

            BodyExerciseTransformer.ToRow(bodyExercise, bodyExerciseRow);
            _dbContext.BodyExercise.Add(bodyExerciseRow);
            _dbContext.SaveChanges();
            return(BodyExerciseTransformer.ToBean(bodyExerciseRow));
        }
Example #2
0
        public static void ToRow(BodyExercise bean, BodyExerciseRow row)
        {
            if (bean == null)
            {
                return;
            }

            row.Id       = bean.Id;
            row.MuscleId = bean.MuscleId;
        }
        public static void ToRow(BodyExercise bean, BodyExerciseRow row)
        {
            if (bean == null)
            {
                return;
            }

            row.Id                   = bean.Id;
            row.MuscleId             = bean.MuscleId;
            row.ExerciseCategoryType = (int)bean.ExerciseCategoryType;
            row.ExerciseUnitType     = (int)bean.ExerciseUnitType;
        }
Example #4
0
        public static void ToRow(BodyExercise bean, BodyExerciseRow row)
        {
            if (bean == null)
            {
                return;
            }

            row.Id       = bean.Id;
            row.MuscleId = bean.MuscleId;
            if (bean.ObjectVersionNumber > 0) // Retrocompatibility
            {
                row.ExerciseCategoryType = (int)bean.ExerciseCategoryType;
                row.ExerciseUnitType     = (int)bean.ExerciseUnitType;
            }
        }
Example #5
0
        internal static BodyExercise ToBean(BodyExerciseRow row)
        {
            if (row == null)
            {
                return(null);
            }

            var bean = new BodyExercise();

            bean.Id = row.Id;
            //bean.Name = Resources.Translation.GetInDB(GetTranslationKey(row.Id));
            //Image name is "{id}.png"
            bean.ImageName = string.Format("{0}.png", row.Id);
            bean.MuscleId  = row.MuscleId;

            return(bean);
        }
Example #6
0
        internal static BodyExercise ToBean(BodyExerciseRow row)
        {
            if (row == null)
            {
                return(null);
            }

            var bean = new BodyExercise();

            bean.Id = row.Id;
            //Image name is "{id}.png"
            bean.ImageName            = string.Format("{0}.png", row.Id);
            bean.MuscleId             = row.MuscleId;
            bean.ExerciseCategoryType = Utils.IntToEnum <TExerciseCategoryType>(row.ExerciseCategoryType ?? (int)TExerciseCategoryType.Bodybuilding);
            bean.ExerciseUnitType     = Utils.IntToEnum <TExerciseUnitType>(row.ExerciseUnitType ?? (int)TExerciseUnitType.RepetitionNumber);

            return(bean);
        }
Example #7
0
        /// <summary>
        /// Create data in database
        /// </summary>
        /// <param name="bodyExercise">Data</param>
        /// <returns>insert data</returns>
        public BodyExercise Create(BodyExercise bodyExercise)
        {
            if (bodyExercise == null)
            {
                return(null);
            }

            if (bodyExercise.Id == 0)
            {
                return(null);
            }

            var bodyExerciseRow = new BodyExerciseRow();

            BodyExerciseTransformer.ToRow(bodyExercise, bodyExerciseRow);
            _dbContext.Insert(bodyExerciseRow);
            return(BodyExerciseTransformer.ToBean(bodyExerciseRow));
        }