private DeleteProviderOrgUnitInsuranceRequest CreateRequest()
 {
     var request = new DeleteProviderOrgUnitInsuranceRequest();
     request.InsuranceId = _idOfInsuranceProviderOrgUnitHas;
     request.ProviderOrgUnitId = _idOfProviderOrgUnitWithInsurances;
     return request;
 }
        private static void SaveInsurances(ProviderAdminDetailView parent, SubEntity subentity, int providerOrgUnitId)
        {
            try
            {
                //New Records
                foreach (var record in subentity.Records.Where(r => r.Action == RecordActions.New))
                {
                    var addServiceRequest = new AddInsuranceRequest()
                    {
                        Name = parent.GetFieldValue(record.Fields, "InsuranceName"),
                        IsEnabled = true
                    };
                    var serviceResponseId = parent.ProcessRequest<AddInsuranceResponse>(addServiceRequest).Id;

                    var request = new AddProviderOrgUnitInsuranceRequest()
                    {
                        ProviderOrgUnitId = providerOrgUnitId,
                        InsuranceId = serviceResponseId
                    };
                    parent.ProcessRequest<AddProviderOrgUnitInsuranceResponse>(request);
                }

                //Added Records
                foreach (var record in subentity.Records.Where(r => r.Action == RecordActions.Added))
                {
                    var request = new AddProviderOrgUnitInsuranceRequest()
                    {
                        ProviderOrgUnitId = providerOrgUnitId,
                        InsuranceId = int.Parse(parent.GetFieldValue(record.Fields, _insuranceId))
                    };
                    parent.ProcessRequest<AddProviderOrgUnitInsuranceResponse>(request);
                }
                foreach (var record in subentity.Records.Where(r => r.Action == RecordActions.Deleted))
                {
                    var request = new DeleteProviderOrgUnitInsuranceRequest()
                    {
                        ProviderOrgUnitId = providerOrgUnitId,
                        InsuranceId = int.Parse(parent.GetFieldValue(record.Fields, _insuranceId))
                    };
                    parent.ProcessRequest<DeleteProviderOrgUnitInsuranceResponse>(request);
                }
            }
            catch (Exception ex)
            {
                subentity.ErrorMessage = ex.Message;
                throw;
            }
        }