예제 #1
0
        public bool CustomFieldCreatingHasNoInitData_PreTransitionCRUD(string transition)
        {
            switch (transition.ToUpper())
            {
            case "ACCEPT":
                if (ASPxEdit.ValidateEditorsInContainer(formlayoutGeneralInfo))
                {
                    using (UnitOfWork uow = XpoHelper.GetNewUnitOfWork())
                    {
                        Guid selectedCustomFieldTypeId =
                            Guid.Parse(cbbCustomFieldType.SelectedItem.Value.ToString());
                        CustomFieldType customFieldType =
                            uow.GetObjectByKey <CustomFieldType>(selectedCustomFieldTypeId);
                        //Create new CustomField
                        NAS.DAL.CMS.ObjectDocument.CustomField customField =
                            new NAS.DAL.CMS.ObjectDocument.CustomField(uow)
                        {
                            CustomFieldId     = Guid.NewGuid(),
                            Name              = txtCustomFieldName.Text,
                            CustomFieldTypeId = customFieldType
                        };
                        //Attach CustomField to ObjectTypeId
                        if (ObjectTypeId != null && !ObjectTypeId.Equals(Guid.Empty))
                        {
                            /*2013-12-12 Khoa.Truong DEL START
                             * Decoupling with the client using this form
                             * //Guid objectTypeId = ((ObjectTypeCustomFieldListing)Parent).ObjectTypeId;
                             * 2013-12-12 Khoa.Truong DEL END*/
                            ObjectType            objectType            = uow.GetObjectByKey <ObjectType>(ObjectTypeId);
                            ObjectTypeCustomField objectTypeCustomField = new ObjectTypeCustomField(uow)
                            {
                                ObjectTypeCustomFieldId = Guid.NewGuid(),
                                CustomFieldId           = customField,
                                ObjectTypeId            = objectType
                            };
                        }
                        //Attach new custom fields for all object of the object type

                        /*These code is replace with lazy updating for custom fields of each object
                         * //ObjectBO objectBO = new ObjectBO();
                         * //objectBO.UpdateCMSObjects(uow, objectTypeId);
                         */

                        uow.CommitChanges();
                    }
                }
                else
                {
                    return(false);
                }
                break;

            default:
                break;
            }
            return(true);
        }
예제 #2
0
        public bool CustomFieldDataCreating_PreTransitionCRUD(string transition)
        {
            switch (transition.ToUpper())
            {
            case "ACCEPT":
                using (UnitOfWork uow = XpoHelper.GetNewUnitOfWork())
                {
                    //Get creating custom field
                    NAS.DAL.CMS.ObjectDocument.CustomField customField =
                        uow.GetObjectByKey <NAS.DAL.CMS.ObjectDocument.CustomField>(CustomFieldId);
                    //Attach CustomField to ObjectTypeId
                    if (ObjectTypeId != null && !ObjectTypeId.Equals(Guid.Empty))
                    {
                        /*2013-12-12 Khoa.Truong DEL START
                         * Decoupling with the client using this form
                         * //Guid objectTypeId = ((ObjectTypeCustomFieldListing)Parent).ObjectTypeId;
                         * 2013-12-12 Khoa.Truong DEL END*/
                        ObjectType            objectType            = uow.GetObjectByKey <ObjectType>(ObjectTypeId);
                        ObjectTypeCustomField objectTypeCustomField = new ObjectTypeCustomField(uow)
                        {
                            ObjectTypeCustomFieldId = Guid.NewGuid(),
                            CustomFieldId           = customField,
                            ObjectTypeId            = objectType
                        };
                    }

                    /*These code is replace with lazy updating for custom fields of each object
                     * ////Attach new custom fields for all object of the object type
                     * //ObjectBO objectBO = new ObjectBO();
                     * //objectBO.UpdateCMSObjects(uow, objectTypeId);
                     */
                    uow.CommitChanges();
                }
                break;

            default:
                break;
            }
            return(true);
        }