Example #1
0
        public bool Save(ISaveable aSauver)
        {
            string docId = $"{aSauver.Table}_{Guid.NewGuid()}";

            ITechnicalKey technicalKey = aSauver as ITechnicalKey;

            if (technicalKey == null)
            {
                return(false);
            }

            MutableDocument document = null;

            if (string.IsNullOrEmpty(technicalKey.Id))
            {
                technicalKey.Id = docId;
            }
            else
            {
                document = _dbConfigurationGetter.Get().GetDocument(technicalKey.Id).ToMutable();
            }

            MutableDictionaryObject dico = aSauver.DocumentInitialize();

            document = dico.ToDocument(docId, document);

            _dbConfigurationGetter.Get().Save(document);

            return(true);
        }
Example #2
0
        public bool Save(ISaveable aSauver)
        {
            string docId = $"{aSauver.Table}_{Guid.NewGuid()}";

            ITechnicalKey technicalKey = aSauver as ITechnicalKey;
            IDateable     dateable     = aSauver as IDateable;

            if (technicalKey == null || dateable == null)
            {
                return(false);
            }

            MutableDocument document = null;

            if (string.IsNullOrEmpty(technicalKey.Id))
            {
                technicalKey.Id       = docId;
                dateable.DateCreation = DateTime.Now;
            }
            else
            {
                if (dateable.DateCreation == DateTime.MinValue)
                {
                    dateable.DateCreation = DateTime.Now;
                }
                dateable.DateModif = DateTime.Now;
                document           = _dataBaseGiver.Get().GetDocument(technicalKey.Id).ToMutable();
            }

            MutableDictionaryObject dico = aSauver.DocumentInitialize();

            document = dico.ToDocument(docId, document);

            _dataBaseGiver.Get().Save(document);

            return(true);
        }