Exemple #1
0
        public virtual bool Create(V item, bool useModelCulture = false)
        {
            if (item == null)
            {
                return(false);
            }

            var result     = true;
            var dataObject = new JoinedItem <T, TT>();

            CopyModelToItem(dataObject, item);
            result &= _rep.Create(dataObject.Item);
            CopyModelToTrans(dataObject, item);
            if (useModelCulture && item is ILocalizableModel)
            {
                dataObject.ItemTranslation.Culture = (item as ILocalizableModel).ContentCulture;
            }
            else
            {
                dataObject.ItemTranslation.Culture = MainCulture;
            }
            result &= _repTrans.Create(dataObject.ItemTranslation);
            result &= _rep.SubmitChanges();

            if (result)
            {
                CopyDataToModel(dataObject, item);
                MergeSubItems(item);
                GetSubItems(item);
            }
            return(result);
        }
        // Note: No longer creates GUID values automatically
        public virtual bool Create(V item)
        {
            var result = false;

            if (item != null)
            {
                var dataObject = new T();
                CopyModelToData(dataObject, item);
                result = repository.Create(dataObject);

                if (result)
                {
                    CopyDataToModel(dataObject, item);
                    MergeSubItems(item);
                    GetSubItems(item);
                }
            }


            return(result);
        }