public IGenericWebApiResult UpdateWithDetail(ParamAdministrasiHakAks data)
        {
            using (var result = new GenericWebApiResult <AdministrasiHakAks>())
            {
                result.Success = genRepo.UpdateWithDetail(data);
                result.Data    = data.HakAkses;
                result.Message = result.Success ? BaseConstants.MESSAGE_UPDATE_SUCCESS : BaseConstants.MESSAGE_INVALID_DATA;

                return(result);
            }
        }
        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);
                }
            }
        }
        public bool UpdateWithDetail(ParamAdministrasiHakAks data)
        {
            using (var trans = ctx.Database.BeginTransaction(IsolationLevel.ReadCommitted))
            {
                try
                {
                    base.Update(data.HakAkses);
                    p_DeleteInsertDetail(data);
                    trans.Commit();

                    return(true);
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    throw new Exception(ex.Message, ex.InnerException);
                }
            }
        }