public bool UpdateWithDetail(AdministrasiRole header, List <AdministrasiRoleDtl> detail) { using (var trans = ctx.Database.BeginTransaction(IsolationLevel.ReadCommitted)) { try { base.Update(header); using (var repoDtl = new AdministrasiRoleDtlRepository(ctx)) { var redcDetail = repoDtl.GetAll().Where(x => x.KodeRole == header.Kode).ToList(); repoDtl.Deletes(redcDetail); //repoDtl.User = this.User; foreach (var dtl in detail) { repoDtl.Create(dtl); } } trans.Commit(); return(true); } catch (Exception ex) { trans.Rollback(); throw new Exception(ex.Message, ex.InnerException); } } }
public bool CreateWithDetail(AdministrasiRole header, List <AdministrasiRoleDtl> detail) { using (var trans = ctx.Database.BeginTransaction(IsolationLevel.ReadCommitted)) { try { base.Create(header); using (var repoDtl = new AdministrasiRoleDtlRepository(ctx)) { foreach (var dtl in detail) { dtl.KodeWilayahKerja = "CE01"; repoDtl.Create(dtl); } } trans.Commit(); return(true); } catch (Exception ex) { trans.Rollback(); throw new Exception(ex.Message, ex.InnerException); } } }