示例#1
0
        /// <summary>
        /// The program can only have one data store. If it has been configured in the program than this will return that path.
        /// </summary>
        /// <returns></returns>
        public CMOptionsDto GetOptions()
        {
            var allOptions = optionsCollection.FindAll();
            var options    = allOptions.FirstOrDefault();

            if (options == null)
            {
                options = new CMOptionsDto();
                optionsCollection.Insert(options);

                OnRecordCreated?.Invoke(
                    new CMDataProviderRecordCreatedEventArgs()
                {
                    CreatedDto = options
                });
            }

            return(options);
        }
示例#2
0
        public CMCUDResult UpdateOptions(CMOptionsDto options)
        {
            var opResult = new CMCUDResult();

            var updateEvent = new CMDataProviderRecordUpdatedEventArgs()
            {
                DtoBefore = GetOptions(),
                DtoAfter  = options,
            };

            if (!optionsCollection.Update(options))
            {
                opResult.Errors.Add("Options were not found in master db.");
                return(opResult);
            }

            OnRecordUpdated?.Invoke(updateEvent);

            return(opResult);
        }