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