/// <summary> /// Create a Subject /// </summary> /// <param name="dto"></param> /// <param name="userName"></param> /// <returns></returns> internal int Create(Subject_DTO dto, string userName) { var inputParams = new List <ADO_inputParams>() { new ADO_inputParams() { name = "@SbjValue", value = dto.SbjValue }, new ADO_inputParams() { name = "@userName", value = userName }, new ADO_inputParams() { name = "@LngIsoCode", value = dto.LngIsoCode } }; var returnParam = new ADO_returnParam() { name = "@ReturnVal", value = 0 }; ado.ExecuteNonQueryProcedure("System_Navigation_Subject_Create", inputParams, ref returnParam); return((int)returnParam.value); }
/// <summary> /// Create and Update a SubjectLanguage /// </summary> /// <param name="dto"></param> /// <param name="Ado"></param> /// <returns></returns> internal int CreateOrUpdate(Subject_DTO dto, ADO Ado) { SubjectLanguage_DTO subjectLanguageDTO = new SubjectLanguage_DTO(); subjectLanguageDTO.SlgValue = dto.SbjValue; subjectLanguageDTO.SbjCode = dto.SbjCode; subjectLanguageDTO.LngIsoCode = dto.LngIsoCode; SubjectLanguage_ADO subjectLanguageADO = new SubjectLanguage_ADO(Ado); return(subjectLanguageADO.CreateOrUpdate(subjectLanguageDTO)); }
/// <summary> /// Deletes a Keyword subject /// </summary> /// <param name="Ado"></param> /// <param name="subjectDto"></param> /// <param name="mandatoryOnly"></param> /// <returns></returns> internal int Delete(ADO Ado, Subject_DTO subjectDto, bool?mandatoryOnly = null) { Keyword_Subject_ADO ksAdo = new Keyword_Subject_ADO(Ado); Keyword_Subject_DTO ksDto = new Keyword_Subject_DTO(); ksDto.SbjCode = subjectDto.SbjCode; if (mandatoryOnly != null) { return(ksAdo.Delete(ksDto, mandatoryOnly)); } else { return(ksAdo.Delete(ksDto)); } }
/// <summary> /// A version of Exists more suitable for update. It tests whether the SbjValue exists on a subject but /// ignores the subject we're trying to update. /// </summary> /// <param name="prcValue"></param> /// <param name="prcCode"></param> /// <returns></returns> internal bool UpdateExists(Subject_DTO dto) { var inputParams = new List <ADO_inputParams>() { new ADO_inputParams() { name = "@SbjValue", value = dto.SbjValue }, new ADO_inputParams() { name = "@LngIsoCode", value = dto.LngIsoCode } }; var reader = ado.ExecuteReaderProcedure("System_Navigation_Subject_Read", inputParams); return(reader.data.Find(e => e.SbjValue == dto.SbjValue && e.SbjCode != dto.SbjCode) != null); }
/// <summary> /// Test if a subject is in place /// </summary> /// <param name="dto"></param> /// <returns></returns> internal bool Exists(Subject_DTO dto) { var inputParams = new List <ADO_inputParams>() { new ADO_inputParams() { name = "@SbjValue", value = dto.SbjValue }, new ADO_inputParams() { name = "@LngIsoCode", value = dto.LngIsoCode } }; var reader = ado.ExecuteReaderProcedure("System_Navigation_Subject_Read", inputParams); return(reader.hasData); }
/// <summary> /// Formats the output /// </summary> /// <param name="rawList"></param> /// <returns></returns> private List <dynamic> formatOutput(List <dynamic> rawList) { Subject_ADO sAdo = new Subject_ADO(Ado); Subject_DTO sDto = new Subject_DTO(); sDto.LngIsoCode = DTO.LngIsoCode; List <dynamic> subjectsReadList = sAdo.Read(sDto); List <dynamic> outList = new List <dynamic>(); foreach (var subject in subjectsReadList) { dynamic dSubject = new ExpandoObject(); dSubject.SbjCode = subject.SbjCode; dSubject.SbjValue = subject.SbjValue; dSubject.product = new List <dynamic>(); foreach (var product in rawList) { if (product.SbjCode == dSubject.SbjCode) { dynamic dProduct = new ExpandoObject(); dProduct.PrcCode = product.PrcCode; dProduct.PrcValue = product.PrcValue; dProduct.PrcReleaseCount = product.PrcReleaseCount; dSubject.product.Add(dProduct); } } if (dSubject.product.Count > 0) { outList.Add(dSubject); } } return(outList); }
internal void Create(ADO Ado, Subject_DTO subjectDto, int subjectID) { //There is no direct means of finding out which langauge the product name uses, // so we take a default language from the settings string languageCode = Utility.GetCustomConfig("APP_KEYWORD_DEFAULT_LANGUAGE_ISO_CODE"); //Create the table that will be bulk inserted DataTable dt = new DataTable(); dt.Columns.Add("KSB_VALUE", typeof(string)); dt.Columns.Add("KSB_SBJ_ID", typeof(int)); dt.Columns.Add("KSB_MANDATORY_FLAG", typeof(bool)); Keyword_Subject_ADO keywordSubjectAdo = new Keyword_Subject_ADO(Ado); //Get a Keyword Extractor - the particular version returned will depend on the language IKeywordExtractor ext = Keyword_BSO_Extract.GetExtractor(languageCode); AddToTable(ref dt, ext.ExtractSplitSingular(subjectDto.SbjValue), subjectID); keywordSubjectAdo.Create(dt); }
internal void Create(ADO Ado, Subject_DTO subjectDto, int subjectID) { //There is no direct means of finding out which langauge the product name uses, // so we take a default language from the settings string languageCode = Configuration_BSO.GetCustomConfig(ConfigType.global, "language.iso.code"); //Create the table that will be bulk inserted DataTable dt = new DataTable(); dt.Columns.Add("KSB_VALUE", typeof(string)); dt.Columns.Add("KSB_SBJ_ID", typeof(int)); dt.Columns.Add("KSB_MANDATORY_FLAG", typeof(bool)); Keyword_Subject_ADO keywordSubjectAdo = new Keyword_Subject_ADO(Ado); //Get a Keyword Extractor - the particular version returned will depend on the language Keyword_BSO_Extract kbe = new Navigation.Keyword_BSO_Extract(languageCode); //IKeywordExtractor ext = kbe.GetExtractor(); AddToTable(ref dt, kbe.ExtractSplitSingular(subjectDto.SbjValue), subjectID); keywordSubjectAdo.Create(dt); }
/// <summary> /// Reads one or more subject /// </summary> /// <param name="dto"></param> /// <returns></returns> internal List <dynamic> Read(Subject_DTO dto) { var inputParams = dto.SbjCode == 0 ? new List <ADO_inputParams>() : new List <ADO_inputParams>() { new ADO_inputParams() { name = "@SbjCode", value = dto.SbjCode } }; if (dto.LngIsoCode != null) { inputParams.Add(new ADO_inputParams() { name = "@LngIsoCode", value = dto.LngIsoCode }); } var reader = ado.ExecuteReaderProcedure("System_Navigation_Subject_Read", inputParams); return(reader.data); }