public virtual T Add(T data) { try { Work.BeginTransaction(); CommonRules(data); AddRules(data); if (!HasErrors) { data = Work.Repository <T>().Add(data); return(data); } else { throw GetBusinessException(); } } catch (FaultException <BusinessException> f) { Rollback(); throw f; } catch (Exception e) { Rollback(); throw new BusinessException(e).GetFaultException(); } finally { Commit(); } }
public virtual T Remove(List <T> datas) { try { List <T> removes = new List <T>(); Work.BeginTransaction(); if (datas != null && datas.Count > 0) { for (int i = 0; i < datas.Count; i++) { RemoveRules(datas[i]); } } if (!HasErrors) { T data = Work.Repository <T>().Remove(datas); return(data); } else { throw GetBusinessException(); } } catch (FaultException <BusinessException> f) { Rollback(); throw f; } catch (Exception e) { Rollback(); throw new BusinessException(e).GetFaultException(); } finally { Commit(); } }