/// <summary>
        /// Complete the submit operation with the specified error.
        /// </summary>
        /// <param name="error">The error.</param>
        internal new void Complete(Exception error)
        {
            if (typeof(DomainException).IsAssignableFrom(error.GetType()))
            {
                // DomainExceptions should not be modified
                base.Complete(error);
                return;
            }

            string message = string.Format(CultureInfo.CurrentCulture,
                                           Resource.DomainContext_SubmitOperationFailed, error.Message);

            DomainOperationException domainOperationException = error as DomainOperationException;

            if (domainOperationException != null)
            {
                error = new SubmitOperationException(ChangeSet, message, domainOperationException);
            }
            else
            {
                error = new SubmitOperationException(ChangeSet, message, error);
            }

            base.Complete(error);
        }
        internal void Complete(OperationErrorStatus errorStatus)
        {
            SubmitOperationException error = null;

            if (errorStatus == OperationErrorStatus.ValidationFailed)
            {
                error = new SubmitOperationException(ChangeSet, Resource.DomainContext_SubmitOperationFailed_Validation, OperationErrorStatus.ValidationFailed);
            }
            else if (errorStatus == OperationErrorStatus.Conflicts)
            {
                error = new SubmitOperationException(ChangeSet, Resource.DomainContext_SubmitOperationFailed_Conflicts, OperationErrorStatus.Conflicts);
            }

            base.Complete(error);
        }
Esempio n. 3
0
        internal void Complete(OperationErrorStatus errorStatus)
        {
            SubmitOperationException error = null;

            if (errorStatus == OperationErrorStatus.ValidationFailed)
            {
                error = new SubmitOperationException(ChangeSet, Resource.DomainContext_SubmitOperationFailed_Validation, OperationErrorStatus.ValidationFailed);
            }
            else if (errorStatus == OperationErrorStatus.Conflicts)
            {
                error = new SubmitOperationException(ChangeSet, Resource.DomainContext_SubmitOperationFailed_Conflicts, OperationErrorStatus.Conflicts);
            }
            else
            {
                // This can never happen, all paths here supply either
                // ValidationFailed or Conflicts
                throw new ArgumentException("Unsupported OperationErrorStatus", nameof(errorStatus));
            }

            base.Complete(error);
        }
        public void DomainOperationException_Ctors()
        {
            var entities = new List<Entity> {new EntityX()};
            var emtpy = new ReadOnlyCollection<Entity>(entities);
            var changeSet = new EntityChangeSet(emtpy, emtpy, emtpy);

            // ctor(changeSet, message, status)
            var soe = new SubmitOperationException(changeSet, "message", OperationErrorStatus.Unauthorized);
            Assert.AreEqual(changeSet, soe.ChangeSet);
            Assert.AreEqual("message", soe.Message, "ctor(msg) failed");
            Assert.IsNull(soe.InnerException, "InnerException s/b null");
            Assert.IsNull(soe.StackTrace, "Default stack trace s/b null");
            Assert.AreEqual(0, soe.ErrorCode, "Error code s/b 0");
            Assert.AreEqual(OperationErrorStatus.Unauthorized, soe.Status, "ctor(msg, status) failed status");
            Assert.IsFalse(soe.ValidationErrors.Any(), "default validationErrors should be empty");

            // ctor(changeSet, message, innerException)
            var ioe = new InvalidOperationException("ioe");
            soe = new SubmitOperationException(changeSet, "message", ioe);
            Assert.AreEqual(changeSet, soe.ChangeSet);
            Assert.AreEqual("message", soe.Message, "ctor(msg) failed");
            Assert.AreSame(ioe, soe.InnerException, "InnerException failed");
            Assert.IsNull(soe.StackTrace, "Default stack trace s/b null");
            Assert.AreEqual(0, soe.ErrorCode, "Error code s/b 0");
            Assert.AreEqual(OperationErrorStatus.ServerError, soe.Status, "Default status s/b ServerError");
            Assert.IsFalse(soe.ValidationErrors.Any(), "default validationErrors should be empty");

            // ctor(changeSet, message, doe)
            var doe2 = new DomainOperationException("message", OperationErrorStatus.Unauthorized, 5, "stackTrace");
            soe = new SubmitOperationException(changeSet, "mm", doe2);
            Assert.AreEqual(changeSet, soe.ChangeSet); 
            Assert.AreEqual("mm", soe.Message, "ctor(doe) failed message");
            Assert.IsNull(soe.InnerException, "InnerException s/b null");
            Assert.AreEqual("stackTrace", soe.StackTrace, "StackTrace failed");
            Assert.AreEqual(5, soe.ErrorCode, "Error code failed");
            Assert.AreEqual(OperationErrorStatus.Unauthorized, soe.Status, "ctor(msg, status) failed status");
            Assert.IsFalse(soe.ValidationErrors.Any(), "default validationErrors should be empty");
        }
Esempio n. 5
0
        /// <summary>
        /// Complete the submit operation with the specified error.
        /// </summary>
        /// <param name="error">The error.</param>
        internal new void Complete(Exception error)
        {
            if (typeof(DomainException).IsAssignableFrom(error.GetType()))
            {
                // DomainExceptions should not be modified
                base.Complete(error);
                return;
            }

            string message = string.Format(CultureInfo.CurrentCulture,
                Resource.DomainContext_SubmitOperationFailed, error.Message);

            DomainOperationException domainOperationException = error as DomainOperationException;
            if (domainOperationException != null)
            {
                error = new SubmitOperationException(ChangeSet, message, domainOperationException);
            }
            else
            {
                error = new SubmitOperationException(ChangeSet, message, error);
            }

            base.Complete(error);
        }
Esempio n. 6
0
        internal void Complete(OperationErrorStatus errorStatus)
        {
            SubmitOperationException error = null;
            if (errorStatus == OperationErrorStatus.ValidationFailed)
            {
                error = new SubmitOperationException(ChangeSet, Resource.DomainContext_SubmitOperationFailed_Validation, OperationErrorStatus.ValidationFailed);
            }
            else if (errorStatus == OperationErrorStatus.Conflicts)
            {
                error = new SubmitOperationException(ChangeSet, Resource.DomainContext_SubmitOperationFailed_Conflicts, OperationErrorStatus.Conflicts);
            }

            base.Complete(error);
        }