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