/// <summary> /// Create data in database /// </summary> /// <param name="muscularGroup">Data</param> /// <returns>insert data</returns> public MuscularGroup Create(MuscularGroup muscularGroup) { if (muscularGroup == null) { return(null); } if (muscularGroup.Id == 0) { var key = new MuscularGroupKey(); var sequencerManager = new SequencerManager(); do { key.Id = sequencerManager.GetNextValue(_dbContext, 1, "muscularGroup"); }while (Get(key) != null); // Test Record exist muscularGroup.Id = key.Id; } if (muscularGroup.Id == 0) { return(null); } var muscularGroupRow = new MuscularGroupRow(); MuscularGroupTransformer.ToRow(muscularGroup, muscularGroupRow); _dbContext.MuscularGroup.Add(muscularGroupRow); _dbContext.SaveChanges(); return(MuscularGroupTransformer.ToBean(muscularGroupRow)); }
/// <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)); }
/// <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)); }
/// <summary> /// Create data in database /// </summary> /// <param name="role">Data</param> /// <returns>insert data</returns> public Role Create(Role role) { if (role == null) { return(null); } if (string.IsNullOrWhiteSpace(role.Id)) { int newId; var key = new RoleKey(); var sequencerManager = new SequencerManager(); do { newId = sequencerManager.GetNextValue(_dbContext, 3, "role"); key.Id = newId.ToString(); }while (Get(key) != null); // Test Record exist if (newId > 0) { role.Id = newId.ToString(); } } if (string.IsNullOrWhiteSpace(role.Id)) { return(null); } var row = new IdentityRole(); RoleTransformer.ToRow(role, row); _dbContext.Roles.Add(row); _dbContext.SaveChanges(); return(RoleTransformer.ToBean(row)); }