Beispiel #1
0
 public NpcMonsterSkillDTO Insert(ref NpcMonsterSkillDTO npcMonsterskill)
 {
     try
     {
         using (var context = DataAccessHelper.CreateContext())
         {
             NpcMonsterSkill entity = _mapper.Map <NpcMonsterSkill>(npcMonsterskill);
             context.NpcMonsterSkill.Add(entity);
             context.SaveChanges();
             return(_mapper.Map <NpcMonsterSkillDTO>(entity));
         }
     }
     catch (Exception e)
     {
         Logger.Error(e);
         return(null);
     }
 }
Beispiel #2
0
 public void Insert(List <NpcMonsterSkillDTO> skills)
 {
     try
     {
         using (var context = DataAccessHelper.CreateContext())
         {
             context.Configuration.AutoDetectChangesEnabled = false;
             foreach (NpcMonsterSkillDTO Skill in skills)
             {
                 NpcMonsterSkill entity = _mapper.Map <NpcMonsterSkill>(Skill);
                 context.NpcMonsterSkill.Add(entity);
             }
             context.Configuration.AutoDetectChangesEnabled = true;
             context.SaveChanges();
         }
     }
     catch (Exception e)
     {
         Logger.Error(e);
     }
 }