/// <summary> /// 编辑emailreceiver /// </summary> /// <param name="dto">实体</param> /// <returns></returns> public bool Update(EmailReceiverDto dto) { using (var scope = _dbScopeFactory.Create()) { var db = GetDb(scope); var dbSet = GetDbSet(db); var entity = Mapper.Map <EmailReceiverDto, EmailReceiverEntity>(dto); dbSet.AddOrUpdate(entity); return(db.SaveChanges() > 0); } }
//private readonly IDbContextScopeFactory _dbScopeFactory; //public EmailReceiverService(IDbContextScopeFactory dbScopeFactory) //{ // _dbScopeFactory = dbScopeFactory; //} #endregion #region IEmailReceiverService 接口实现 /// <summary> /// 添加emailreceiver /// </summary> /// <param name="dto">emailreceiver实体</param> /// <returns></returns> public string Add(EmailReceiverDto dto) { using (var scope = _dbScopeFactory.Create()) { var db = GetDb(scope); var dbSet = GetDbSet(db); var entity = Mapper.Map <EmailReceiverDto, EmailReceiverEntity>(dto); entity.Create(); dbSet.Add(entity); scope.SaveChanges(); return(entity.Id); } }
/// <summary> /// 编辑emailreceiver /// </summary> /// <param name="dto">实体</param> /// <returns></returns> public void Update(EmailReceiverDto dto) { var entity = Mapper.Map <EmailReceiverDto, EmailReceiver>(dto); repository.Update(entity); }
/// <summary> /// 添加emailreceiver /// </summary> /// <param name="dto">emailreceiver实体</param> /// <returns></returns> public void Add(EmailReceiverDto dto) { var entity = Mapper.Map <EmailReceiverDto, EmailReceiver>(dto); repository.Insert(entity); }