Esempio n. 1
0
        public CodeRuleData Insert(Session session, Guid codeRuleDefinitionId, Guid codeRuleDataFormatId)
        {
            CodeRuleData codeRuleData = null;

            try
            {
                //Get CodeRuleDefinition
                CodeRuleDefinition codeRuleDefinition = session.GetObjectByKey <CodeRuleDefinition>(codeRuleDefinitionId);
                //Get CodeRuleDataFormat
                CodeRuleDataFormat codeRuleDataFormat = session.GetObjectByKey <CodeRuleDataFormat>(codeRuleDataFormatId);
                //Create new CodeRuleStringData
                codeRuleData = new CodeRuleData(session)
                {
                    CodeRuleDataFormatId = codeRuleDataFormat,
                    CodeRuleDataId       = Guid.NewGuid(),
                    CodeRuleDefinitionId = codeRuleDefinition,
                    CreateDate           = DateTime.Now,
                    RowStatus            = Utility.Constant.ROWSTATUS_ACTIVE
                };
                codeRuleData.Save();
                return(codeRuleData);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Esempio n. 2
0
        public CodeRuleData Update(Session session, Guid codeRuleDefinitionId, Guid codeRuleDataFormatId)
        {
            CodeRuleData codeRuleData = null;

            try
            {
                CodeRuleDataBO codeRuleDataBO = new CodeRuleDataBO();
                //Check updating CodeRuleDataType already exist
                //Get CodeRuleDataFormat
                CodeRuleDataFormat codeRuleDataFormat =
                    session.GetObjectByKey <CodeRuleDataFormat>(codeRuleDataFormatId);

                //Get CodeRuleDefinition
                CodeRuleDefinition codeRuleDefinition =
                    session.GetObjectByKey <CodeRuleDefinition>(codeRuleDefinitionId);

                codeRuleData = (CodeRuleData)codeRuleDataBO.GetCodeRuleData(session,
                                                                            codeRuleDefinition.CodeRuleDefinitionId,
                                                                            codeRuleDataFormat.CodeRuleDataTypeId.CodeRuleDataTypeId);

                foreach (var item in codeRuleDefinition.CodeRuleData)
                {
                    item.RowStatus = Utility.Constant.ROWSTATUS_INACTIVE;
                    item.Save();
                }

                if (codeRuleData == null)
                {
                    codeRuleData = Insert(session, codeRuleDefinition.CodeRuleDefinitionId, codeRuleDataFormatId);
                }
                else
                {
                    codeRuleData.CodeRuleDataFormatId = codeRuleDataFormat;
                    codeRuleData.RowStatus            = Utility.Constant.ROWSTATUS_ACTIVE;
                    codeRuleData.Save();
                }

                return(codeRuleData);
            }
            catch (Exception ex)
            {
                throw;
            }
        }