/// <summary> /// Execute /// </summary> /// <returns></returns> protected override bool Execute() { //Validation of parameters and user have been successful. We may now proceed to read from the database var adoSubject = new Subject_ADO(Ado); //You can only create a subject in the default Language DTO.LngIsoCode = Configuration_BSO.GetCustomConfig("language.iso.code"); //We can't allow duplicate named Subjects, so we must check first if (adoSubject.Exists(DTO)) { Response.error = Label.Get("error.duplicate"); return(false); } //Create the Subject - and retrieve the newly created Id int newId = adoSubject.Create(DTO, SamAccountName); if (newId == 0) { Response.error = Label.Get("error.create"); return(false); } //We must create the search keywords for this subject Keyword_Subject_BSO_Mandatory bsoKeyword = new Keyword_Subject_BSO_Mandatory(); bsoKeyword.Create(Ado, DTO, newId); Response.data = JSONRPC.success; return(true); }
/// <summary> /// Execute /// </summary> /// <returns></returns> protected override bool Execute() { var adoSubject = new Subject_ADO(Ado); int nUpdatedSubjectId = 0; //We can't allow duplicate named Subjects, so we must check first if (adoSubject.UpdateExists(DTO)) { Response.error = Label.Get("error.duplicate"); return(false); } if (DTO.LngIsoCode != Configuration_BSO.GetCustomConfig(ConfigType.global, "language.iso.code")) { SubjectLanguage_BSO subjectLanguageBso = new SubjectLanguage_BSO(); nUpdatedSubjectId = subjectLanguageBso.CreateOrUpdate(DTO, Ado); if (nUpdatedSubjectId == 0) { Log.Instance.Debug("Update of SubjectLanguage failed"); Response.error = Label.Get("error.update"); return(false); } } else { nUpdatedSubjectId = adoSubject.Update(DTO, SamAccountName); } if (nUpdatedSubjectId == 0) { Log.Instance.Debug("Update of Subject failed"); Response.error = Label.Get("error.update"); return(false); } //We must now delete all of the keywords for the subject Keyword_Subject_BSO_Mandatory kbBso = new Keyword_Subject_BSO_Mandatory(); int nchanged = kbBso.Delete(Ado, DTO, true); if (nchanged == 0) { Log.Instance.Debug("No keywords deleted"); } //We can now recreate the keywords for the subject kbBso.Create(Ado, DTO, nUpdatedSubjectId); //Reset the relevant caches MemCacheD.CasRepositoryFlush(Resources.Constants.C_CAS_NAVIGATION_SEARCH); MemCacheD.CasRepositoryFlush(Resources.Constants.C_CAS_NAVIGATION_READ); Response.data = JSONRPC.success; return(true); }