/// <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 adoTheme = new Theme_ADO(Ado); //You can only create a theme in the default Language DTO.LngIsoCode = Configuration_BSO.GetCustomConfig(ConfigType.global, "language.iso.code"); //We can't allow duplicate named Themes, so we must check first if (adoTheme.Exists(new Theme_DTO_Read() { LngIsoCode = DTO.LngIsoCode, ThmValue = DTO.ThmValue })) { Response.error = Label.Get("error.duplicate"); return(false); } //Create the Theme - and retrieve the newly created Id int newId = adoTheme.Create(DTO, SamAccountName); if (newId == 0) { Response.error = Label.Get("error.create"); return(false); } Response.data = JSONRPC.success; return(true); }
/// <summary> /// Execute /// </summary> /// <returns></returns> protected override bool Execute() { var adoTheme = new Theme_ADO(Ado); var list = adoTheme.Read(DTO); Response.data = list; return(true); }
/// <summary> /// Formats the output /// </summary> /// <param name="rawList"></param> /// <returns></returns> private List <dynamic> formatOutput(List <dynamic> rawList) { Theme_ADO tAdo = new Theme_ADO(Ado); List <dynamic> themeReadList = tAdo.Read(new Theme_DTO_Read() { LngIsoCode = DTO.LngIsoCode }); List <dynamic> outList = new List <dynamic>(); foreach (var theme in themeReadList) { dynamic dTheme = new ExpandoObject(); dTheme.ThmCode = theme.ThmCode; dTheme.ThmValue = theme.ThmValue; dTheme.subject = new List <dynamic>(); var subjectList = new List <dynamic>(); foreach (var subject in rawList) { if (subject.ThmCode == dTheme.ThmCode && subjectList.Where(x => x.SbjCode == subject.SbjCode).Count() == 0) { 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); } } subjectList.Add(dSubject); } } dTheme.subject = subjectList; if (dTheme.subject.Count > 0) { outList.Add(dTheme); } } return(outList); }
/// <summary> /// Execute /// </summary> /// <returns></returns> protected override bool Execute() { var adoTheme = new Theme_ADO(Ado); int nUpdatedThemeId; //We can't allow duplicate named Themes, so we must check first if (adoTheme.UpdateExists(new Theme_DTO_Read() { LngIsoCode = DTO.LngIsoCode, ThmCode = DTO.ThmCode, ThmValue = DTO.ThmValue })) { Response.error = Label.Get("error.duplicate"); return(false); } if (DTO.LngIsoCode != Configuration_BSO.GetCustomConfig(ConfigType.global, "language.iso.code")) { ThemeLanguage_BSO themeLanguageBso = new ThemeLanguage_BSO(); nUpdatedThemeId = themeLanguageBso.CreateOrUpdate(DTO, Ado); if (nUpdatedThemeId == 0) { Log.Instance.Debug("Update of ThemeLanguage failed"); Response.error = Label.Get("error.update"); return(false); } } else { nUpdatedThemeId = adoTheme.Update(DTO, SamAccountName); } if (nUpdatedThemeId == 0) { Log.Instance.Debug("Update of Theme failed"); Response.error = Label.Get("error.update"); return(false); } Response.data = JSONRPC.success; return(true); }
/// <summary> /// Execute /// </summary> /// <returns></returns> protected override bool Execute() { var adoTheme = new Theme_ADO(Ado); //attempting to delete. The number of entities deleted are passed to the entitiesDeleted variable (this is 1 for a successful delete) int nDeleted = adoTheme.Delete(DTO, SamAccountName); Log.Instance.Debug("Delete operation finished in ADO"); if (nDeleted == 0) { Log.Instance.Debug("No record found for delete request"); Response.error = Label.Get("error.delete"); return(false); } Response.data = JSONRPC.success; return(true); }