public bool DeleteWithDetail(string kode)
        {
            using (var trans = ctx.Database.BeginTransaction(IsolationLevel.ReadCommitted))
            {
                try
                {
                    var model = base.GetSingle(kode);
                    base.Delete(model);
                    using (var repoHakAksesRole = new AdministrasiHakAksesRoleRepository(ctx))
                    {
                        var detail = repoHakAksesRole.GetAll().Where(x => x.KodeHakAkses == kode).ToList();
                        repoHakAksesRole.Deletes(detail);
                    }
                    using (var repoHakAksesMenu = new AdministrasiHakAksesMenuRepository(ctx))
                    {
                        var detail = repoHakAksesMenu.GetAll().Where(x => x.KodeHakAkses == kode).ToList();
                        repoHakAksesMenu.Deletes(detail);
                    }
                    using (var repoHakAksesTombol = new AdministrasiHakAksesTombolRepository(ctx))
                    {
                        var detail = repoHakAksesTombol.GetAll().Where(x => x.KodeHakAkses == kode).ToList();
                        repoHakAksesTombol.Deletes(detail);
                    }
                    trans.Commit();

                    return(true);
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    throw new Exception(ex.Message, ex.InnerException);
                }
            }
        }
        private void p_DeleteInsertDetail(ParamAdministrasiHakAks data)
        {
            var kode = data.HakAkses.Kode;

            using (var repoHakAksesRole = new AdministrasiHakAksesRoleRepository(ctx))
            {
                repoHakAksesRole.UserProfile = this.UserProfile;

                var records = repoHakAksesRole.GetAll().Where(x => x.KodeHakAkses == kode).ToList();
                repoHakAksesRole.Deletes(records);

                foreach (var mdl in data.Roles)
                {
                    mdl.KodeHakAkses = kode;
                    repoHakAksesRole.Create(mdl);
                }
            }

            using (var repoHakAksesMenu = new AdministrasiHakAksesMenuRepository(ctx))
            {
                repoHakAksesMenu.UserProfile = this.UserProfile;

                var records = repoHakAksesMenu.GetAll().Where(x => x.KodeHakAkses == kode).ToList();
                repoHakAksesMenu.Deletes(records);

                foreach (var mdl in data.Menus)
                {
                    mdl.KodeHakAkses = kode;
                    repoHakAksesMenu.Create(mdl);
                }
            }

            using (var repoHakAksesTombol = new AdministrasiHakAksesTombolRepository(ctx))
            {
                repoHakAksesTombol.UserProfile = this.UserProfile;

                var records = repoHakAksesTombol.GetAll().Where(x => x.KodeHakAkses == kode).ToList();
                repoHakAksesTombol.Deletes(records);

                foreach (var mdl in data.Tombols)
                {
                    mdl.KodeHakAkses = kode;
                    repoHakAksesTombol.Create(mdl);
                }
            }
        }