protected virtual void btnInsert_Click(object sender, EventArgs e) { try { IndividualCertification indCert = new IndividualCertification(); indCert.CertificationId = Convert.ToInt32(this.certification.SelectedValue); indCert.NBSId = Convert.ToInt32(this.individual.SelectedValue); indCert.ActivationDate = Convert.ToDateTime(this.activationDate.Text); indCert.ExpirationDate = Convert.ToDateTime(this.expirationDate.Text); indCert.CertificationNumber = this.certificationNumber.Text; indCert.State = this.stateCode.Text; indCert.Country = this.countryCode.Text; NinthBrainSuiteAPI.IndividualCertificationService.Insert(indCert); ShowMessage("The IndividualCertification was Inserted."); } catch (IllegalArgumentException illegalEx) { ShowErrorMessage(GetExceptionsDetails(illegalEx, "IllegalArgumentException")); } catch (NinthBrainAPIException nbEx) { ShowErrorMessage( GetExceptionsDetails(nbEx, "NinthBrainAPIException")); } catch (Exception ex) { ShowErrorMessage(GetExceptionsDetails(ex, "Exception")); } }
/// <summary> /// /// </summary> /// <param name="configuration"></param> /// <param name="individualCertificationId"></param> /// <returns></returns> public IndividualCertification GetIndividualCertification(int individualCertificationId) { IndividualCertification certification = new IndividualCertification(); // Construct access URL //string url = (pag == null) ? Config.ConstructUrl(Config.Endpoints.Certifications, null, new object[] { "email", email, "limit", limit, "modified_since", Extensions.ToISO8601String(modifiedSince), "status", status }) : pag.GetNextUrl(); string url = Config.ConstructUrl("IndividualCertification/GetIndividualCertification", null, new object[] { "individualCertificationId", individualCertificationId.ToString() }); // Get REST response CUrlResponse response = RestClient.Get(url, configuration); if (response.IsError) { throw new NinthBrainAPIException(response.GetErrorMessage()); } if (response.HasData) { // Convert from JSON certification = Component.FromJSON<IndividualCertification>(response.Body); } return certification; }
/// <summary> /// /// </summary> /// <param name="individualCertification"></param> /// <returns></returns> public IndividualCertification Update(IndividualCertification individualCertification) { IndividualCertification updatedIndividualCertification = null; string url = "IndividualCertification/Update"; string json = individualCertification.ToJSON(); CUrlResponse response = RestClient.Post(url, configuration, json); if (response.HasData) { updatedIndividualCertification = Component.FromJSON<IndividualCertification>(response.Body); } else if (response.IsError) { throw new NinthBrainAPIException(response.GetErrorMessage()); } return updatedIndividualCertification; }