示例#1
0
        /// <summary>
        /// Sets the result Message to the exception message and the Outcome as an InternalError (500).
        /// </summary>
        /// <param name="ex">Exception to parse</param>
        /// <returns>CreateResult<typeparamref name="T"/> with an InternalError (500) outcome and message</returns>
        public static CreateResult <T> HandleException(Exception ex)
        {
            CreateResult <T> result = new CreateResult <T>();

            result.SetError(ex);
            return(result);
        }
示例#2
0
        /// <summary>
        /// Sets the result Message to the passed in message and the Outcome as an Created (201).
        /// </summary>
        /// <param name="artifact">Artifact to be returned to the end user</param>
        /// <returns>CreateResult<typeparamref name="T"/> with an Created (201) outcome and message</returns>
        public static CreateResult <T> Created(T artifact)
        {
            CreateResult <T> result = new CreateResult <T>();

            result.Outcome  = MetrikOutcome.Created;
            result.Artifact = artifact;
            return(result);
        }
示例#3
0
        /// <summary>
        /// Sets the result Message to the passed in message and the Outcome as an InternalError (500).
        /// </summary>
        /// <param name="message">Message describing the error</param>
        /// <returns>CreateResult<typeparamref name="T"/> with an InternalError (500) outcome and message</returns>
        public static CreateResult <T> InternalError(string message)
        {
            CreateResult <T> result = new CreateResult <T>();

            result.Outcome  = MetrikOutcome.InternalError;
            result.Message  = message;
            result.Artifact = null;
            return(result);
        }
示例#4
0
        /// <summary>
        /// Sets the result Message to the passed in message and the Outcome as an Conflict (409).
        /// </summary>
        /// <param name="message">Message describing the conflict</param>
        /// <returns>CreateResult<typeparamref name="T"/> with an Conflict (409) outcome and message</returns>
        public static CreateResult <T> Conflict(string message)
        {
            CreateResult <T> result = new CreateResult <T>();

            result.Outcome  = MetrikOutcome.Conflict;
            result.Message  = message;
            result.Artifact = null;
            return(result);
        }