Exemplo n.º 1
0
        /// <summary>
        /// Saves the specified property definition and commits it to the database.
        /// </summary>
        /// <param name="PropertyDef">The PropertyDefinition.</param>
        /// <returns></returns>
        public OperationReport Save(PropertyDefinition PropertyDef)
        {
            OperationReport validationReport = GuardAgainstNulls.ArgsContainsNull(new object[] { PropertyDef });

            if (!validationReport.Success)
            {
                throw new OrcaArgumentNullException(validationReport);
            }

            OperationReport result = new OperationReport();

            try
            {
                IPersistCommandsTransaction trans = GetPersistTransactionFor(PropertyDef.Id);
                if (trans != null)
                {
                    if (newPropertyDefintions.ContainsKey(PropertyDef.Id))
                    {
                        if (PropertyDefinitionNameAvaliable(PropertyDef.Name))
                        {
                            NameToTypeAssociation propertyDefNameRegistration = RegisterPropertyDefintionName(PropertyDef.Name);
                            trans.Save(propertyDefNameRegistration);
                        }
                        else
                        {
                            throw new PropertyNameAlreadyDefinedException(PropertyDef.Name);
                        }
                    }
                    else
                    {
                        trans.SaveOrUpdate(PropertyDef);
                    }
                    result = persistor.ProcessCommandsTransaction(trans);

                    if (result.Success)
                    {
                        lock (newPropertyDefintions)
                        {
                            newPropertyDefintions.Remove(PropertyDef.Id);
                        }
                    }
                    else
                    {
                        //not sure what to do
                    }
                }
            }
            catch (Exception ex)
            {
                result.Success = false;
                result.AddNotification(ex.Message, ex);
            }

            return(result);
        }
Exemplo n.º 2
0
        private IPersistCommandsTransaction GetPersistTransactionFor(Guid DomainObjectId)
        {
            IPersistCommandsTransaction transaction = persistor.GetTransaction(DomainObjectId);

            return(transaction);
        }