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); } }
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); } }