public static void MergeWith(this ModelStateDictionary modelStateDictionary, ExecutionResult executionResult)
        {
            if (executionResult == null) return;

            var messageGroups =
                executionResult
                    .Errors
                    .Select(e => e.Value);

            foreach (var messageGroup in messageGroups)
            {
                AddErrorMessage(modelStateDictionary, messageGroup);

                foreach (var propertyName in messageGroup.PropertyNames)
                {
                    modelStateDictionary.AddModelError(propertyName ?? string.Empty, " ");
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Merge another application message into the current one
        /// </summary>
        /// <param name="executionResult"></param>
        public ExecutionResult Merge(ExecutionResult executionResult)
        {
            if (executionResult != null)
            {
                foreach (var item in executionResult.All)
                {
                    Add(item.Key, item.Value);
                }
            }

            #region append what is affected and what the user can do

            var whatIsAffected = new List<String>();

            if (executionResult.WhatIsAffected != null)
            {
                whatIsAffected = executionResult.WhatIsAffected.ToList();
            }

            if (this.WhatIsAffected != null)
            {
                var list = this.WhatIsAffected.ToList();

                list.AddRange(whatIsAffected);

                whatIsAffected = list;
            }

            this.WhatIsAffected = whatIsAffected;

            var whatTheUserCanDo = new List<String>();

            if (executionResult.WhatTheUserCanDo != null)
            {
                whatTheUserCanDo = executionResult.WhatTheUserCanDo.ToList();
            }

            if (this.WhatTheUserCanDo != null)
            {
                var list = this.WhatTheUserCanDo.ToList();
                list.AddRange(whatTheUserCanDo);

                whatTheUserCanDo = list;
            }

            this.WhatTheUserCanDo = whatTheUserCanDo;

            return this;
        }
Exemplo n.º 3
0
 /// <summary>
 /// Merge another application message into this newly built one
 /// </summary>
 /// <param name="executionResult"></param>
 public ExecutionResult(ExecutionResult executionResult)
 {
     Merge(executionResult);
 }
 public ExecutionResultAssertions(ExecutionResult executionResult)
 {
     ExecutionResult = executionResult;
 }