예제 #1
0
        public bool DeleteWithDetail(string kode)
        {
            using (var trans = ctx.Database.BeginTransaction(IsolationLevel.ReadCommitted))
            {
                try
                {
                    var model = base.GetSingle(kode);
                    base.Delete(model);
                    using (var repoDtl = new AdministrasiRoleDtlRepository(ctx))
                    {
                        repoDtl.UserProfile = this.UserProfile;

                        var detail = repoDtl.GetAll().Where(x => x.KodeRole == kode).ToList();
                        repoDtl.Deletes(detail);
                    }
                    trans.Commit();

                    return(true);
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    throw new Exception(ex.Message, ex.InnerException);
                }
            }
        }
예제 #2
0
        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);
                }
            }
        }