Exemplo n.º 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));
     }
 }
Exemplo n.º 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();
     }
 }
Exemplo n.º 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);
     }
 }