Exemple #1
0
 public ShopSkillDTO Insert(ShopSkillDTO shopSkill)
 {
     using (var context = DataAccessHelper.CreateContext())
     {
         ShopSkill entity = _mapper.Map <ShopSkill>(shopSkill);
         context.ShopSkill.Add(entity);
         context.SaveChanges();
         return(_mapper.Map <ShopSkillDTO>(entity));
     }
 }
Exemple #2
0
 public void Insert(List <ShopSkillDTO> skills)
 {
     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();
     }
 }
Exemple #3
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);
     }
 }