Esempio n. 1
0
 public MapNpcDTO Insert(MapNpcDTO npc)
 {
     using (var context = DataAccessHelper.CreateContext())
     {
         MapNpc entity = _mapper.Map <MapNpc>(npc);
         context.MapNpc.Add(entity);
         context.SaveChanges();
         return(_mapper.Map <MapNpcDTO>(entity));
     }
 }
Esempio n. 2
0
 public void Insert(List <MapNpcDTO> npcs)
 {
     using (var context = DataAccessHelper.CreateContext())
     {
         context.Configuration.AutoDetectChangesEnabled = false;
         foreach (MapNpcDTO Item in npcs)
         {
             MapNpc entity = _mapper.Map <MapNpc>(Item);
             context.MapNpc.Add(entity);
         }
         context.Configuration.AutoDetectChangesEnabled = true;
         context.SaveChanges();
     }
 }
 public MapNpcDTO Insert(MapNpcDTO npc)
 {
     try
     {
         using (var context = DataAccessHelper.CreateContext())
         {
             MapNpc entity = _mapper.Map <MapNpc>(npc);
             context.MapNpc.Add(entity);
             context.SaveChanges();
             return(_mapper.Map <MapNpcDTO>(entity));
         }
     }
     catch (Exception e)
     {
         Logger.Error(e);
         return(null);
     }
 }