Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Execute
        /// </summary>
        /// <returns></returns>
        protected override bool Execute()
        {
            var adoSubject = new Subject_ADO(Ado);
            var list       = adoSubject.Read(DTO);

            Response.data = list;

            return(true);
        }
Ejemplo n.º 3
0
        /// <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);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Execute
        /// </summary>
        /// <returns></returns>
        protected override bool Execute()
        {
            var adoSubject = new Subject_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 = adoSubject.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);
        }
Ejemplo n.º 5
0
        /// <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);
        }