private AddProviderCertificationSpecialtyRequest CreateRequest(int providerId)
 {
     var request = new AddProviderCertificationSpecialtyRequest();
     request.ProviderId = providerId;
     request.CertificationSpecialtyId = _CertificationSpecialtyTypeId;
     request.YearOfIssuance = "2003";
     return request;
 }
        public static void Save(ProviderAdminDetailView parent, SubEntity providerCertificationSpecialties, int providerId)
        {
            try
            {
                providerCertificationSpecialties.ErrorMessage = string.Empty;

                //Edits
                foreach (var record in providerCertificationSpecialties.Records.Where(r => r.Action == RecordActions.Edited))
                {
                    var yearOfIssuance = Validate(parent, record);

                    var request = new UpdateProviderCertificationSpecialtyRequest();

                    request.Id = int.Parse(parent.GetFieldValue(record.Fields, _id));
                    request.ProviderId = providerId;
                    request.CertificationSpecialtyId = int.Parse(parent.GetFieldValue(record.Fields, _certificationSpecialtyId));
                    request.YearOfIssuance = yearOfIssuance;

                    parent.ProcessRequest<UpdateProviderCertificationSpecialtyResponse>(request);
                }

                //Existing Records Added
                foreach (var record in providerCertificationSpecialties.Records.Where(r => r.Action == RecordActions.Added))
                {
                    var yearOfIssuance = Validate(parent, record);

                    var request = new AddProviderCertificationSpecialtyRequest()
                    {
                        ProviderId = providerId,
                        CertificationSpecialtyId = int.Parse(parent.GetFieldValue(record.Fields, _certificationSpecialtyId)),
                        YearOfIssuance = yearOfIssuance
                    };

                    parent.ProcessRequest<AddProviderCertificationSpecialtyResponse>(request);
                }

                //Deletes
                foreach (var record in providerCertificationSpecialties.Records.Where(r => r.Action == RecordActions.Deleted))
                {
                    var request = new DeleteProviderCertificationSpecialtyRequest()
                    {
                        ProviderId = providerId,
                        CertificationSpecialtyId = int.Parse(parent.GetFieldValue(record.Fields, _certificationSpecialtyId))
                    };
                    parent.ProcessRequest<DeleteProviderCertificationSpecialtyResponse>(request);
                }
            }
            catch (Exception ex)
            {
                providerCertificationSpecialties.ErrorMessage = ex.Message;
                throw;
            }

            providerCertificationSpecialties = BuildCertificationSubEntity(parent, providerId);
        }