Exemplo n.º 1
0
 public void SeedClassLevel(string seedDataPath)
 {
     ClassLevelSeed[] classArray;
     using (var classStream = new StreamReader(seedDataPath + "/classtable.json"))
     {
         classArray = JsonConvert.DeserializeObject <ClassLevelSeed[]>(classStream.ReadToEnd());
     }
     foreach (var classLevelSeed in classArray)
     {
         var dbClass = _classProgressionRepository.GetById(classLevelSeed.Id);
         if (dbClass == null)
         {
             var newClass = ClassLevelMapper.MapSeedToEntity(classLevelSeed);
             newClass.CreatedBy = "SeedClassLevel";
             newClass.SeedData  = true;
             _classProgressionRepository.Add(newClass);
         }
         else
         {
             ClassLevelMapper.MapSeedToEntity(classLevelSeed, dbClass);
             dbClass.ModifiedBy = "SeedClassLevel";
             _classProgressionRepository.Update(dbClass);
         }
     }
 }
Exemplo n.º 2
0
        public ClassLevelViewModel AddClassLevel(ClassLevelViewModel classLevel)
        {
            var classLevelEntity = ClassLevelMapper.MapModelToEntity(classLevel);

            classLevelEntity.CreatedBy = "TEST";
            classLevelEntity.SeedData  = false;
            var addedClassLevel = _classProgressionRepository.Add(classLevelEntity);

            return(ClassLevelMapper.MapEntityToModel(addedClassLevel));
        }
Exemplo n.º 3
0
        public ClassLevelViewModel UpdateClassLevel(int id, ClassLevelViewModel classLevel)
        {
            var originalClassLevel = _classProgressionRepository.GetById(id);

            ClassLevelMapper.MapModelToEntity(classLevel, originalClassLevel);
            originalClassLevel.ModifiedBy = "TEST";
            var updatedClassLevel = _classProgressionRepository.Update(originalClassLevel);

            return(ClassLevelMapper.MapEntityToModel(updatedClassLevel));
        }
Exemplo n.º 4
0
 public ClassLevelViewModel GetClassLevelById(int id)
 {
     return(ClassLevelMapper.MapEntityToModel(_classProgressionRepository.GetById(id)));
 }