StatusCodeResult

We found 10 examples in language CSharp for this search. You will see 48 fragments of code.
using System.Net;

namespace Blueprint.Http
{
    /// <summary>
    /// <para>
    /// A simple <see cref="HttpResult" /> that can be used when no content needs writing, only a status code and (optional)
    /// headers.
    /// </para>
    /// <para>
    /// It is recommended to declare return types as a specific subclass of this (i.e. <see cref="StatusCodeResult.Created" />)
    /// to provide additional metadata with regards to expected responses to enable a more comprehensive and accurate OpenApi
    /// document to be created.
    /// </para>
    /// </summary>
    public partial class StatusCodeResult
    {
        /// <summary>
        /// A <see cref="StatusCodeResult" /> for the status <see cref="HttpStatusCode.Continue" />.
        /// </summary>
        public sealed class Continue : StatusCodeResult
        {
            /// <summary>
            /// The static instance of the <see cref="StatusCodeResult.Continue" /> class.
            /// </summary>
            public static readonly Continue Instance = new Continue();

            /// <summary>
            /// Initializes a new instance of the <see cref="StatusCodeResult.Continue" /> class.
            /// </summary>
            private Continue()
                : base(HttpStatusCode.Continue)
            {
            }
        }

        /// <summary>
        /// A <see cref="StatusCodeResult" /> for the status <see cref="HttpStatusCode.SwitchingProtocols" />.
        /// </summary>
        public sealed class SwitchingProtocols : StatusCodeResult
        {
            /// <summary>
            /// The static instance of the <see cref="StatusCodeResult.SwitchingProtocols" /> class.
            /// </summary>
            public static readonly SwitchingProtocols Instance = new SwitchingProtocols();

            /// <summary>
            /// Initializes a new instance of the <see cref="StatusCodeResult.SwitchingProtocols" /> class.
            /// </summary>
            private SwitchingProtocols()
                : base(HttpStatusCode.SwitchingProtocols)
            {
            }
        }

        /// <summary>
        /// A <see cref="StatusCodeResult" /> for the status <see cref="HttpStatusCode.OK" />.
        /// </summary>
        public sealed class OK : StatusCodeResult
        {
            /// <summary>
            /// The static instance of the <see cref="StatusCodeResult.OK" /> class.
            /// </summary>
            public static readonly OK Instance = new OK();

            /// <summary>
            /// Initializes a new instance of the <see cref="StatusCodeResult.OK" /> class.
            /// </summary>
            private OK()
                : base(HttpStatusCode.OK)
            {
            }
        }

        /// <summary>
        /// A <see cref="StatusCodeResult" /> for the status <see cref="HttpStatusCode.Created" />.
        /// </summary>
        public sealed class Created : StatusCodeResult
        {
            /// <summary>
            /// The static instance of the <see cref="StatusCodeResult.Created" /> class.
            /// </summary>
            public static readonly Created Instance = new Created();

            /// <summary>
            /// Initializes a new instance of the <see cref="StatusCodeResult.Created" /> class.
            /// </summary>
            private Created()
                : base(HttpStatusCode.Created)
            {
            }
        }

        /// <summary>
        /// A <see cref="StatusCodeResult" /> for the status <see cref="HttpStatusCode.Accepted" />.
        /// </summary>
        public sealed class Accepted : StatusCodeResult
        {
            /// <summary>
            /// The static instance of the <see cref="StatusCodeResult.Accepted" /> class.
            /// </summary>
            public static readonly Accepted Instance = new Accepted();

            /// <summary>
            /// Initializes a new instance of the <see cref="StatusCodeResult.Accepted" /> class.
            /// </summary>
            private Accepted()
                : base(HttpStatusCode.Accepted)
            {
            }
        }

        /// <summary>
        /// A <see cref="StatusCodeResult" /> for the status <see cref="HttpStatusCode.NonAuthoritativeInformation" />.
        /// </summary>
        public sealed class NonAuthoritativeInformation : StatusCodeResult
        {
            /// <summary>
            /// The static instance of the <see cref="StatusCodeResult.NonAuthoritativeInformation" /> class.
            /// </summary>
            public static readonly NonAuthoritativeInformation Instance = new NonAuthoritativeInformation();

            /// <summary>
            /// Initializes a new instance of the <see cref="StatusCodeResult.NonAuthoritativeInformation" /> class.
            /// </summary>
            private NonAuthoritativeInformation()
                : base(HttpStatusCode.NonAuthoritativeInformation)
            {
            }
        }

        /// <summary>
        /// A <see cref="StatusCodeResult" /> for the status <see cref="HttpStatusCode.NoContent" />.
        /// </summary>
        public sealed class NoContent : StatusCodeResult
        {
            /// <summary>
            /// The static instance of the <see cref="StatusCodeResult.NoContent" /> class.
            /// </summary>
            public static readonly NoContent Instance = new NoContent();

            /// <summary>
            /// Initializes a new instance of the <see cref="StatusCodeResult.NoContent" /> class.
            /// </summary>
            private NoContent()
                : base(HttpStatusCode.NoContent)
            {
            }
        }

        /// <summary>
        /// A <see cref="StatusCodeResult" /> for the status <see cref="HttpStatusCode.ResetContent" />.
        /// </summary>
        public sealed class ResetContent : StatusCodeResult
        {
            /// <summary>
            /// The static instance of the <see cref="StatusCodeResult.ResetContent" /> class.
            /// </summary>
            public static readonly ResetContent Instance = new ResetContent();

            /// <summary>
            /// Initializes a new instance of the <see cref="StatusCodeResult.ResetContent" /> class.
            /// </summary>
            private ResetContent()
                : base(HttpStatusCode.ResetContent)
            {
            }
        }

        /// <summary>
        /// A <see cref="StatusCodeResult" /> for the status <see cref="HttpStatusCode.PartialContent" />.
        /// </summary>
        public sealed class PartialContent : StatusCodeResult
        {
            /// <summary>
            /// The static instance of the <see cref="StatusCodeResult.PartialContent" /> class.
            /// </summary>
            public static readonly PartialContent Instance = new PartialContent();

            /// <summary>
            /// Initializes a new instance of the <see cref="StatusCodeResult.PartialContent" /> class.
            /// </summary>
            private PartialContent()
                : base(HttpStatusCode.PartialContent)
            {
            }
        }

        /// <summary>
        /// A <see cref="StatusCodeResult" /> for the status <see cref="HttpStatusCode.MultipleChoices" />.
        /// </summary>
        public sealed class MultipleChoices : StatusCodeResult
        {
            /// <summary>
            /// The static instance of the <see cref="StatusCodeResult.MultipleChoices" /> class.
            /// </summary>
            public static readonly MultipleChoices Instance = new MultipleChoices();

            /// <summary>
            /// Initializes a new instance of the <see cref="StatusCodeResult.MultipleChoices" /> class.
            /// </summary>
            private MultipleChoices()
                : base(HttpStatusCode.MultipleChoices)
            {
            }
        }

        /// <summary>
        /// A <see cref="StatusCodeResult" /> for the status <see cref="HttpStatusCode.Ambiguous" />.
        /// </summary>
        public sealed class Ambiguous : StatusCodeResult
        {
            /// <summary>
            /// The static instance of the <see cref="StatusCodeResult.Ambiguous" /> class.
            /// </summary>
            public static readonly Ambiguous Instance = new Ambiguous();

            /// <summary>
            /// Initializes a new instance of the <see cref="StatusCodeResult.Ambiguous" /> class.
            /// </summary>
            private Ambiguous()
                : base(HttpStatusCode.Ambiguous)
            {
            }
        }

        /// <summary>
        /// A <see cref="StatusCodeResult" /> for the status <see cref="HttpStatusCode.MovedPermanently" />.
        /// </summary>
        public sealed class MovedPermanently : StatusCodeResult
        {
            /// <summary>
            /// The static instance of the <see cref="StatusCodeResult.MovedPermanently" /> class.
            /// </summary>
            public static readonly MovedPermanently Instance = new MovedPermanently();

            /// <summary>
            /// Initializes a new instance of the <see cref="StatusCodeResult.MovedPermanently" /> class.
            /// </summary>
            private MovedPermanently()
                : base(HttpStatusCode.MovedPermanently)
            {
            }
        }

        /// <summary>
        /// A <see cref="StatusCodeResult" /> for the status <see cref="HttpStatusCode.Moved" />.
        /// </summary>
        public sealed class Moved : StatusCodeResult
        {
            /// <summary>
            /// The static instance of the <see cref="StatusCodeResult.Moved" /> class.
            /// </summary>
            public static readonly Moved Instance = new Moved();

            /// <summary>
            /// Initializes a new instance of the <see cref="StatusCodeResult.Moved" /> class.
            /// </summary>
            private Moved()
                : base(HttpStatusCode.Moved)
            {
            }
        }

        /// <summary>
        /// A <see cref="StatusCodeResult" /> for the status <see cref="HttpStatusCode.Found" />.
        /// </summary>
        public sealed class Found : StatusCodeResult
        {
            /// <summary>
            /// The static instance of the <see cref="StatusCodeResult.Found" /> class.
            /// </summary>
            public static readonly Found Instance = new Found();

            /// <summary>
            /// Initializes a new instance of the <see cref="StatusCodeResult.Found" /> class.
            /// </summary>
            private Found()
                : base(HttpStatusCode.Found)
            {
            }
        }

        /// <summary>
        /// A <see cref="StatusCodeResult" /> for the status <see cref="HttpStatusCode.Redirect" />.
        /// </summary>
        public sealed class Redirect : StatusCodeResult
        {
            /// <summary>
            /// The static instance of the <see cref="StatusCodeResult.Redirect" /> class.
            /// </summary>
            public static readonly Redirect Instance = new Redirect();

            /// <summary>
            /// Initializes a new instance of the <see cref="StatusCodeResult.Redirect" /> class.
            /// </summary>
            private Redirect()
                : base(HttpStatusCode.Redirect)
            {
            }
        }

        /// <summary>
        /// A <see cref="StatusCodeResult" /> for the status <see cref="HttpStatusCode.SeeOther" />.
        /// </summary>
        public sealed class SeeOther : StatusCodeResult
        {
            /// <summary>
            /// The static instance of the <see cref="StatusCodeResult.SeeOther" /> class.
            /// </summary>
            public static readonly SeeOther Instance = new SeeOther();

            /// <summary>
            /// Initializes a new instance of the <see cref="StatusCodeResult.SeeOther" /> class.
            /// </summary>
            private SeeOther()
                : base(HttpStatusCode.SeeOther)
            {
            }
        }

        /// <summary>
        /// A <see cref="StatusCodeResult" /> for the status <see cref="HttpStatusCode.RedirectMethod" />.
        /// </summary>
        public sealed class RedirectMethod : StatusCodeResult
        {
            /// <summary>
            /// The static instance of the <see cref="StatusCodeResult.RedirectMethod" /> class.
            /// </summary>
            public static readonly RedirectMethod Instance = new RedirectMethod();

            /// <summary>
            /// Initializes a new instance of the <see cref="StatusCodeResult.RedirectMethod" /> class.
            /// </summary>
            private RedirectMethod()
                : base(HttpStatusCode.RedirectMethod)
            {
            }
        }

        /// <summary>
        /// A <see cref="StatusCodeResult" /> for the status <see cref="HttpStatusCode.NotModified" />.
        /// </summary>
        public sealed class NotModified : StatusCodeResult
        {
            /// <summary>
            /// The static instance of the <see cref="StatusCodeResult.NotModified" /> class.
            /// </summary>
            public static readonly NotModified Instance = new NotModified();

            /// <summary>
            /// Initializes a new instance of the <see cref="StatusCodeResult.NotModified" /> class.
            /// </summary>
            private NotModified()
                : base(HttpStatusCode.NotModified)
            {
            }
        }

        /// <summary>
        /// A <see cref="StatusCodeResult" /> for the status <see cref="HttpStatusCode.UseProxy" />.
        /// </summary>
        public sealed class UseProxy : StatusCodeResult
        {
            /// <summary>
            /// The static instance of the <see cref="StatusCodeResult.UseProxy" /> class.
            /// </summary>
            public static readonly UseProxy Instance = new UseProxy();

            /// <summary>
            /// Initializes a new instance of the <see cref="StatusCodeResult.UseProxy" /> class.
            /// </summary>
            private UseProxy()
                : base(HttpStatusCode.UseProxy)
            {
            }
        }

        /// <summary>
        /// A <see cref="StatusCodeResult" /> for the status <see cref="HttpStatusCode.Unused" />.
        /// </summary>
        public sealed class Unused : StatusCodeResult
        {
            /// <summary>
            /// The static instance of the <see cref="StatusCodeResult.Unused" /> class.
            /// </summary>
            public static readonly Unused Instance = new Unused();

            /// <summary>
            /// Initializes a new instance of the <see cref="StatusCodeResult.Unused" /> class.
            /// </summary>
            private Unused()
                : base(HttpStatusCode.Unused)
            {
            }
        }

        /// <summary>
        /// A <see cref="StatusCodeResult" /> for the status <see cref="HttpStatusCode.TemporaryRedirect" />.
        /// </summary>
        public sealed class TemporaryRedirect : StatusCodeResult
        {
            /// <summary>
            /// The static instance of the <see cref="StatusCodeResult.TemporaryRedirect" /> class.
            /// </summary>
            public static readonly TemporaryRedirect Instance = new TemporaryRedirect();

            /// <summary>
            /// Initializes a new instance of the <see cref="StatusCodeResult.TemporaryRedirect" /> class.
            /// </summary>
            private TemporaryRedirect()
                : base(HttpStatusCode.TemporaryRedirect)
            {
            }
        }

        /// <summary>
        /// A <see cref="StatusCodeResult" /> for the status <see cref="HttpStatusCode.RedirectKeepVerb" />.
        /// </summary>
        public sealed class RedirectKeepVerb : StatusCodeResult
        {
            /// <summary>
            /// The static instance of the <see cref="StatusCodeResult.RedirectKeepVerb" /> class.
            /// </summary>
            public static readonly RedirectKeepVerb Instance = new RedirectKeepVerb();

            /// <summary>
            /// Initializes a new instance of the <see cref="StatusCodeResult.RedirectKeepVerb" /> class.
            /// </summary>
            private RedirectKeepVerb()
                : base(HttpStatusCode.RedirectKeepVerb)
            {
            }
        }

        /// <summary>
        /// A <see cref="StatusCodeResult" /> for the status <see cref="HttpStatusCode.BadRequest" />.
        /// </summary>
        public sealed class BadRequest : StatusCodeResult
        {
            /// <summary>
            /// The static instance of the <see cref="StatusCodeResult.BadRequest" /> class.
            /// </summary>
            public static readonly BadRequest Instance = new BadRequest();

            /// <summary>
            /// Initializes a new instance of the <see cref="StatusCodeResult.BadRequest" /> class.
            /// </summary>
            private BadRequest()
                : base(HttpStatusCode.BadRequest)
            {
            }
        }

        /// <summary>
        /// A <see cref="StatusCodeResult" /> for the status <see cref="HttpStatusCode.Unauthorized" />.
        /// </summary>
        public sealed class Unauthorized : StatusCodeResult
        {
            /// <summary>
            /// The static instance of the <see cref="StatusCodeResult.Unauthorized" /> class.
            /// </summary>
            public static readonly Unauthorized Instance = new Unauthorized();

            /// <summary>
            /// Initializes a new instance of the <see cref="StatusCodeResult.Unauthorized" /> class.
            /// </summary>
            private Unauthorized()
                : base(HttpStatusCode.Unauthorized)
            {
            }
        }

        /// <summary>
        /// A <see cref="StatusCodeResult" /> for the status <see cref="HttpStatusCode.PaymentRequired" />.
        /// </summary>
        public sealed class PaymentRequired : StatusCodeResult
        {
            /// <summary>
            /// The static instance of the <see cref="StatusCodeResult.PaymentRequired" /> class.
            /// </summary>
            public static readonly PaymentRequired Instance = new PaymentRequired();

            /// <summary>
            /// Initializes a new instance of the <see cref="StatusCodeResult.PaymentRequired" /> class.
            /// </summary>
            private PaymentRequired()
                : base(HttpStatusCode.PaymentRequired)
            {
            }
        }

        /// <summary>
        /// A <see cref="StatusCodeResult" /> for the status <see cref="HttpStatusCode.Forbidden" />.
        /// </summary>
        public sealed class Forbidden : StatusCodeResult
        {
            /// <summary>
            /// The static instance of the <see cref="StatusCodeResult.Forbidden" /> class.
            /// </summary>
            public static readonly Forbidden Instance = new Forbidden();

            /// <summary>
            /// Initializes a new instance of the <see cref="StatusCodeResult.Forbidden" /> class.
            /// </summary>
            private Forbidden()
                : base(HttpStatusCode.Forbidden)
            {
            }
        }

        /// <summary>
        /// A <see cref="StatusCodeResult" /> for the status <see cref="HttpStatusCode.NotFound" />.
        /// </summary>
        public sealed class NotFound : StatusCodeResult
        {
            /// <summary>
            /// The static instance of the <see cref="StatusCodeResult.NotFound" /> class.
            /// </summary>
            public static readonly NotFound Instance = new NotFound();

            /// <summary>
            /// Initializes a new instance of the <see cref="StatusCodeResult.NotFound" /> class.
            /// </summary>
            private NotFound()
                : base(HttpStatusCode.NotFound)
            {
            }
        }

        /// <summary>
        /// A <see cref="StatusCodeResult" /> for the status <see cref="HttpStatusCode.MethodNotAllowed" />.
        /// </summary>
        public sealed class MethodNotAllowed : StatusCodeResult
        {
            /// <summary>
            /// The static instance of the <see cref="StatusCodeResult.MethodNotAllowed" /> class.
            /// </summary>
            public static readonly MethodNotAllowed Instance = new MethodNotAllowed();

            /// <summary>
            /// Initializes a new instance of the <see cref="StatusCodeResult.MethodNotAllowed" /> class.
            /// </summary>
            private MethodNotAllowed()
                : base(HttpStatusCode.MethodNotAllowed)
            {
            }
        }

        /// <summary>
        /// A <see cref="StatusCodeResult" /> for the status <see cref="HttpStatusCode.NotAcceptable" />.
        /// </summary>
        public sealed class NotAcceptable : StatusCodeResult
        {
            /// <summary>
            /// The static instance of the <see cref="StatusCodeResult.NotAcceptable" /> class.
            /// </summary>
            public static readonly NotAcceptable Instance = new NotAcceptable();

            /// <summary>
            /// Initializes a new instance of the <see cref="StatusCodeResult.NotAcceptable" /> class.
            /// </summary>
            private NotAcceptable()
                : base(HttpStatusCode.NotAcceptable)
            {
            }
        }

        /// <summary>
        /// A <see cref="StatusCodeResult" /> for the status <see cref="HttpStatusCode.ProxyAuthenticationRequired" />.
        /// </summary>
        public sealed class ProxyAuthenticationRequired : StatusCodeResult
        {
            /// <summary>
            /// The static instance of the <see cref="StatusCodeResult.ProxyAuthenticationRequired" /> class.
            /// </summary>
            public static readonly ProxyAuthenticationRequired Instance = new ProxyAuthenticationRequired();

            /// <summary>
            /// Initializes a new instance of the <see cref="StatusCodeResult.ProxyAuthenticationRequired" /> class.
            /// </summary>
            private ProxyAuthenticationRequired()
                : base(HttpStatusCode.ProxyAuthenticationRequired)
            {
            }
        }

        /// <summary>
        /// A <see cref="StatusCodeResult" /> for the status <see cref="HttpStatusCode.RequestTimeout" />.
        /// </summary>
        public sealed class RequestTimeout : StatusCodeResult
        {
            /// <summary>
            /// The static instance of the <see cref="StatusCodeResult.RequestTimeout" /> class.
            /// </summary>
            public static readonly RequestTimeout Instance = new RequestTimeout();

            /// <summary>
            /// Initializes a new instance of the <see cref="StatusCodeResult.RequestTimeout" /> class.
            /// </summary>
            private RequestTimeout()
                : base(HttpStatusCode.RequestTimeout)
            {
            }
        }

        /// <summary>
        /// A <see cref="StatusCodeResult" /> for the status <see cref="HttpStatusCode.Conflict" />.
        /// </summary>
        public sealed class Conflict : StatusCodeResult
        {
            /// <summary>
            /// The static instance of the <see cref="StatusCodeResult.Conflict" /> class.
            /// </summary>
            public static readonly Conflict Instance = new Conflict();

            /// <summary>
            /// Initializes a new instance of the <see cref="StatusCodeResult.Conflict" /> class.
            /// </summary>
            private Conflict()
                : base(HttpStatusCode.Conflict)
            {
            }
        }

        /// <summary>
        /// A <see cref="StatusCodeResult" /> for the status <see cref="HttpStatusCode.Gone" />.
        /// </summary>
        public sealed class Gone : StatusCodeResult
        {
            /// <summary>
            /// The static instance of the <see cref="StatusCodeResult.Gone" /> class.
            /// </summary>
            public static readonly Gone Instance = new Gone();

            /// <summary>
            /// Initializes a new instance of the <see cref="StatusCodeResult.Gone" /> class.
            /// </summary>
            private Gone()
                : base(HttpStatusCode.Gone)
            {
            }
        }

        /// <summary>
        /// A <see cref="StatusCodeResult" /> for the status <see cref="HttpStatusCode.LengthRequired" />.
        /// </summary>
        public sealed class LengthRequired : StatusCodeResult
        {
            /// <summary>
            /// The static instance of the <see cref="StatusCodeResult.LengthRequired" /> class.
            /// </summary>
            public static readonly LengthRequired Instance = new LengthRequired();

            /// <summary>
            /// Initializes a new instance of the <see cref="StatusCodeResult.LengthRequired" /> class.
            /// </summary>
            private LengthRequired()
                : base(HttpStatusCode.LengthRequired)
            {
            }
        }

        /// <summary>
        /// A <see cref="StatusCodeResult" /> for the status <see cref="HttpStatusCode.PreconditionFailed" />.
        /// </summary>
        public sealed class PreconditionFailed : StatusCodeResult
        {
            /// <summary>
            /// The static instance of the <see cref="StatusCodeResult.PreconditionFailed" /> class.
            /// </summary>
            public static readonly PreconditionFailed Instance = new PreconditionFailed();

            /// <summary>
            /// Initializes a new instance of the <see cref="StatusCodeResult.PreconditionFailed" /> class.
            /// </summary>
            private PreconditionFailed()
                : base(HttpStatusCode.PreconditionFailed)
            {
            }
        }

        /// <summary>
        /// A <see cref="StatusCodeResult" /> for the status <see cref="HttpStatusCode.RequestEntityTooLarge" />.
        /// </summary>
        public sealed class RequestEntityTooLarge : StatusCodeResult
        {
            /// <summary>
            /// The static instance of the <see cref="StatusCodeResult.RequestEntityTooLarge" /> class.
            /// </summary>
            public static readonly RequestEntityTooLarge Instance = new RequestEntityTooLarge();

            /// <summary>
            /// Initializes a new instance of the <see cref="StatusCodeResult.RequestEntityTooLarge" /> class.
            /// </summary>
            private RequestEntityTooLarge()
                : base(HttpStatusCode.RequestEntityTooLarge)
            {
            }
        }

        /// <summary>
        /// A <see cref="StatusCodeResult" /> for the status <see cref="HttpStatusCode.RequestUriTooLong" />.
        /// </summary>
        public sealed class RequestUriTooLong : StatusCodeResult
        {
            /// <summary>
            /// The static instance of the <see cref="StatusCodeResult.RequestUriTooLong" /> class.
            /// </summary>
            public static readonly RequestUriTooLong Instance = new RequestUriTooLong();

            /// <summary>
            /// Initializes a new instance of the <see cref="StatusCodeResult.RequestUriTooLong" /> class.
            /// </summary>
            private RequestUriTooLong()
                : base(HttpStatusCode.RequestUriTooLong)
            {
            }
        }

        /// <summary>
        /// A <see cref="StatusCodeResult" /> for the status <see cref="HttpStatusCode.UnsupportedMediaType" />.
        /// </summary>
        public sealed class UnsupportedMediaType : StatusCodeResult
        {
            /// <summary>
            /// The static instance of the <see cref="StatusCodeResult.UnsupportedMediaType" /> class.
            /// </summary>
            public static readonly UnsupportedMediaType Instance = new UnsupportedMediaType();

            /// <summary>
            /// Initializes a new instance of the <see cref="StatusCodeResult.UnsupportedMediaType" /> class.
            /// </summary>
            private UnsupportedMediaType()
                : base(HttpStatusCode.UnsupportedMediaType)
            {
            }
        }

        /// <summary>
        /// A <see cref="StatusCodeResult" /> for the status <see cref="HttpStatusCode.RequestedRangeNotSatisfiable" />.
        /// </summary>
        public sealed class RequestedRangeNotSatisfiable : StatusCodeResult
        {
            /// <summary>
            /// The static instance of the <see cref="StatusCodeResult.RequestedRangeNotSatisfiable" /> class.
            /// </summary>
            public static readonly RequestedRangeNotSatisfiable Instance = new RequestedRangeNotSatisfiable();

            /// <summary>
            /// Initializes a new instance of the <see cref="StatusCodeResult.RequestedRangeNotSatisfiable" /> class.
            /// </summary>
            private RequestedRangeNotSatisfiable()
                : base(HttpStatusCode.RequestedRangeNotSatisfiable)
            {
            }
        }

        /// <summary>
        /// A <see cref="StatusCodeResult" /> for the status <see cref="HttpStatusCode.ExpectationFailed" />.
        /// </summary>
        public sealed class ExpectationFailed : StatusCodeResult
        {
            /// <summary>
            /// The static instance of the <see cref="StatusCodeResult.ExpectationFailed" /> class.
            /// </summary>
            public static readonly ExpectationFailed Instance = new ExpectationFailed();

            /// <summary>
            /// Initializes a new instance of the <see cref="StatusCodeResult.ExpectationFailed" /> class.
            /// </summary>
            private ExpectationFailed()
                : base(HttpStatusCode.ExpectationFailed)
            {
            }
        }

        /// <summary>
        /// A <see cref="StatusCodeResult" /> for the status <see cref="HttpStatusCode.UpgradeRequired" />.
        /// </summary>
        public sealed class UpgradeRequired : StatusCodeResult
        {
            /// <summary>
            /// The static instance of the <see cref="StatusCodeResult.UpgradeRequired" /> class.
            /// </summary>
            public static readonly UpgradeRequired Instance = new UpgradeRequired();

            /// <summary>
            /// Initializes a new instance of the <see cref="StatusCodeResult.UpgradeRequired" /> class.
            /// </summary>
            private UpgradeRequired()
                : base(HttpStatusCode.UpgradeRequired)
            {
            }
        }

        /// <summary>
        /// A <see cref="StatusCodeResult" /> for the status <see cref="HttpStatusCode.InternalServerError" />.
        /// </summary>
        public sealed class InternalServerError : StatusCodeResult
        {
            /// <summary>
            /// The static instance of the <see cref="StatusCodeResult.InternalServerError" /> class.
            /// </summary>
            public static readonly InternalServerError Instance = new InternalServerError();

            /// <summary>
            /// Initializes a new instance of the <see cref="StatusCodeResult.InternalServerError" /> class.
            /// </summary>
            private InternalServerError()
                : base(HttpStatusCode.InternalServerError)
            {
            }
        }

        /// <summary>
        /// A <see cref="StatusCodeResult" /> for the status <see cref="HttpStatusCode.NotImplemented" />.
        /// </summary>
        public sealed class NotImplemented : StatusCodeResult
        {
            /// <summary>
            /// The static instance of the <see cref="StatusCodeResult.NotImplemented" /> class.
            /// </summary>
            public static readonly NotImplemented Instance = new NotImplemented();

            /// <summary>
            /// Initializes a new instance of the <see cref="StatusCodeResult.NotImplemented" /> class.
            /// </summary>
            private NotImplemented()
                : base(HttpStatusCode.NotImplemented)
            {
            }
        }

        /// <summary>
        /// A <see cref="StatusCodeResult" /> for the status <see cref="HttpStatusCode.BadGateway" />.
        /// </summary>
        public sealed class BadGateway : StatusCodeResult
        {
            /// <summary>
            /// The static instance of the <see cref="StatusCodeResult.BadGateway" /> class.
            /// </summary>
            public static readonly BadGateway Instance = new BadGateway();

            /// <summary>
            /// Initializes a new instance of the <see cref="StatusCodeResult.BadGateway" /> class.
            /// </summary>
            private BadGateway()
                : base(HttpStatusCode.BadGateway)
            {
            }
        }

        /// <summary>
        /// A <see cref="StatusCodeResult" /> for the status <see cref="HttpStatusCode.ServiceUnavailable" />.
        /// </summary>
        public sealed class ServiceUnavailable : StatusCodeResult
        {
            /// <summary>
            /// The static instance of the <see cref="StatusCodeResult.ServiceUnavailable" /> class.
            /// </summary>
            public static readonly ServiceUnavailable Instance = new ServiceUnavailable();

            /// <summary>
            /// Initializes a new instance of the <see cref="StatusCodeResult.ServiceUnavailable" /> class.
            /// </summary>
            private ServiceUnavailable()
                : base(HttpStatusCode.ServiceUnavailable)
            {
            }
        }

        /// <summary>
        /// A <see cref="StatusCodeResult" /> for the status <see cref="HttpStatusCode.GatewayTimeout" />.
        /// </summary>
        public sealed class GatewayTimeout : StatusCodeResult
        {
            /// <summary>
            /// The static instance of the <see cref="StatusCodeResult.GatewayTimeout" /> class.
            /// </summary>
            public static readonly GatewayTimeout Instance = new GatewayTimeout();

            /// <summary>
            /// Initializes a new instance of the <see cref="StatusCodeResult.GatewayTimeout" /> class.
            /// </summary>
            private GatewayTimeout()
                : base(HttpStatusCode.GatewayTimeout)
            {
            }
        }

        /// <summary>
        /// A <see cref="StatusCodeResult" /> for the status <see cref="HttpStatusCode.HttpVersionNotSupported" />.
        /// </summary>
        public sealed class HttpVersionNotSupported : StatusCodeResult
        {
            /// <summary>
            /// The static instance of the <see cref="StatusCodeResult.HttpVersionNotSupported" /> class.
            /// </summary>
            public static readonly HttpVersionNotSupported Instance = new HttpVersionNotSupported();

            /// <summary>
            /// Initializes a new instance of the <see cref="StatusCodeResult.HttpVersionNotSupported" /> class.
            /// </summary>
            private HttpVersionNotSupported()
                : base(HttpStatusCode.HttpVersionNotSupported)
            {
            }
        }

        }
}


        // get all employees
        [AllowAnonymous]
        [HttpGet]
        [Route("employees")]
        public async Task<ActionResult<List<EmployeeDepartmentDTO>>> GetEmployees(bool includeDepartments = false)
        {

            try{
                return new OkObjectResult(await _employeeService.GetEmployees(includeDepartments));
            }
            catch{
                return new StatusCodeResult(500);
            }
        }

        // get employee by id
        [AllowAnonymous]
        [HttpGet]
        [Route("employee/{employeeId}")]
        public async Task<ActionResult<List<EmployeeDTO>>> GetEmployee(Guid employeeId)
        {

            try{
                return new OkObjectResult(await _employeeService.GetEmployee(employeeId));
            }
            catch{
                return new StatusCodeResult(500);
            }
        }

        // add an employee
        [AllowAnonymous]
        [HttpPost]
        [Route("employees")]
        public async Task<ActionResult<EmployeeDTO>> AddEmployee(Employee employee)
        {
            try{
                return new OkObjectResult(await _employeeService.AddEmployee(employee));
            }
            catch{
                return new StatusCodeResult(500);
            }
        }

        // delete an employee
        [HttpDelete]
        [Route("employee/{employeeId}")]
        public async Task<ActionResult> DeleteEmployee(Guid employeeId)
        {
            try{
                await _employeeService.DeleteEmployee(employeeId);
                return Ok();
            }
            catch{
                return new StatusCodeResult(500);
            }
        }

        // get departments
        [AllowAnonymous]
        [HttpGet]
        [Route("departments")]
        public async Task<ActionResult<List<Department>>> GetDepartments()
        {
            try{
                return new OkObjectResult(await _employeeService.GetDepartments());
            }
            catch{
                return new StatusCodeResult(500);
            }
        }

        // get department by id
        [AllowAnonymous]
        [HttpGet]
        [Route("department/{departmentId}")]
        public async Task<ActionResult<Department>> GetDepartment(Guid departmentId)
        {
            try{
                return new OkObjectResult(await _employeeService.GetDepartment(departmentId));
            }
            catch{
                return new StatusCodeResult(500);
            }
        }




        // URL: api/event
        [HttpGet]
        public ActionResult<List<EventDataReadDTO>> Get()
        {
            try
            {
                // retrieve and convert data
                List<Event> foundEvents = _eControl.Get();
                List<EventDataReadDTO> foundDTOs = ModelConversion.EventDataReadDTOConvert.FromEventCollection(foundEvents);
                // evaluate

                if (foundDTOs is null) return new StatusCodeResult(500); // internal server error
                if (foundDTOs.Count() is 0) return new StatusCodeResult(204); // Ok, but no content
                return Ok(foundDTOs); // Statuscode 200
            }
            catch
            {
                return new StatusCodeResult(404);
            }
            
        }

        [HttpGet("{id:int}")]
        public ActionResult<EventDataReadDTO> Get(int Id)
        {
            try
            {
                ActionResult<EventDataReadDTO> foundReturn;
                Event foundEvent = _eControl.Get(Id);
                EventDataReadDTO foundDTOs = ModelConversion.EventDataReadDTOConvert.FromEvent(foundEvent);

                if (foundDTOs is null) return new StatusCodeResult(500); // internal server error
                if (foundDTOs.Id is <= 0) return new StatusCodeResult(204); // Ok, but no content
                return Ok(foundDTOs); // Statuscode 200
            }
            catch
            {
                return new StatusCodeResult(404);
            }
            
        }

        [HttpDelete("{id:int}")]
        public ActionResult<String> Delete(int id)
        {
            try
            {
                Event foundEvent = _eControl.Get(id);
                _eControl.Delete(foundEvent);

                if (foundEvent is null) return new StatusCodeResult(500); // internal server error
                if (foundEvent.Id is <= 0) return new StatusCodeResult(204); // Ok, but no content
                return Ok(foundEvent); // Statuscode 200
            }
            catch
            {
                return new StatusCodeResult(404);
            }

        }

        [HttpPost]
        public ActionResult<string> PostEvent(EventDataCreateDTO postEvent)
        {
            try
            {
                string loggedInId = postEvent.AspNetFK;
                int profileId = _pControl.GetProfileByUserIdValue(loggedInId);
                if (profileId == -1) return new StatusCodeResult(500);

                postEvent.ProfileId = profileId;
                Event dbEvent = ModelConversion.EventDataCreateDTOConvert.ToEvent(postEvent);
                int eventId = _eControl.Add(dbEvent);
                if (eventId is -1) return new StatusCodeResult(500); // internal server error
                if (eventId is <= 0) return new StatusCodeResult(204); // Ok, but no content
                return new StatusCodeResult(200);
            }
            catch
            {
                return new StatusCodeResult(404);
            }
        }

        [HttpPut]
        public ActionResult<string> Update(EventDataCreateDTO putEvent)
        {
            try
            {
                Event dbEvent = ModelConversion.EventDataCreateDTOConvert.ToEvent(putEvent);
                _eControl.Put(dbEvent);
                return new StatusCodeResult(200);
            }
            catch
            {
                return new StatusCodeResult(404);
            }
        }

        [Fact]
        public async Task Add_SendDataWithoutCreatingSequence()
        {
            // Arrange
            var mockDb = new Mock<MyDb>();
            var controller = new ObservationController(mockDb.Object);
            int expectedCode = 404;
            string expectedResponse = "{ status = error, msg = The�sequence�isn't�found }";
            var obseq = new ObservationWithSequence();

            // Act
            var actionResult = await controller.Add(obseq);

            // Assert
            var statusCodeResult = (IStatusCodeActionResult)actionResult;
            var response = ((ObjectResult)actionResult).Value.ToString();
            Assert.Equal(expectedCode, statusCodeResult.StatusCode);
            Assert.Equal(expectedResponse, response);
        }

        [Fact]
        public async Task Add_1110111_0011101()
        {
            // Arrange
            var mockDb = new Mock<MyDb>();
            Guid sequence = Guid.NewGuid();
            var observation = new Observation();
            var sd = new SeqData();
            //create sequence
            await mockDb.Object.Set(sequence, sd);
            //arrange data to send
            var obseq = new ObservationWithSequence();
            obseq.observation = new Observation();
            observation.color = "green";
            observation.numbers = new List<string>() { "1110111", "0011101" };
            obseq.sequence = sequence;
            obseq.observation = observation;
            int expectedCode = 200;
            string expectedResponse = "{ status = ok, response = { start = [2,8,82,88], missing = [0000000,1000000] } }";
            var controller = new ObservationController(mockDb.Object);

            // Act
            var actionResult = await controller.Add(obseq);

            // Assert
            var statusCodeResult = (IStatusCodeActionResult)actionResult;
            var response = ((ObjectResult)actionResult).Value.ToString();
            ;
            Assert.Equal(expectedCode, statusCodeResult.StatusCode);
            Assert.Equal(expectedResponse, response);
        }

        [Fact]
        public async Task Add_1110111_0011101_and_1110111_0010000()
        {
            // Arrange to create sequence
            var mockDb = new Mock<MyDb>();
            Guid sequence = Guid.NewGuid();
            var observation = new Observation();
            var sd = new SeqData();
            //create sequence
            await mockDb.Object.Set(sequence, sd);
            int expectedCode = 200;
            string expectedResponse = "{ status = ok, response = { start = [2,8,82,88], missing = [0000000,1000010] } }";
            var controller = new ObservationController(mockDb.Object);

            //arrange data to send 1110111_0011101
            var obseq = new ObservationWithSequence();
            observation = new Observation();
            observation.color = "green";
            observation.numbers = new List<string>() { "1110111", "0011101" };
            obseq.sequence = sequence;
            obseq.observation = observation;

            // Act 1
            var actionResult1 = await controller.Add(obseq);

            //arrange data to send 1110111_0010000
            var obseq2 = new ObservationWithSequence();
            var observation2 = new Observation();
            observation2.color = "green";
            observation2.numbers = new List<string>() { "1110111", "0010000" };
            obseq2.sequence = sequence;
            obseq2.observation = observation2;

            // Act 2
            var actionResult2 = await controller.Add(obseq2);

            // Assert
            var statusCodeResult = (IStatusCodeActionResult)actionResult2;
            var response = ((ObjectResult)actionResult2).Value.ToString();
            ;
            Assert.Equal(expectedCode, statusCodeResult.StatusCode);
            Assert.Equal(expectedResponse, response);
        }

        [Fact]
        public async Task Add_1110111_0011101_and_1110111_0010000_and_red()
        {
            // Arrange
            var mockDb = new Mock<MyDb>();
            Guid sequence = Guid.NewGuid();
            var observation = new Observation();
            var sd = new SeqData();
            //create sequence
            await mockDb.Object.Set(sequence, sd);
            int expectedCode = 200;
            string expectedResponse = "{ status = ok, response = { start = [2], missing = [0000000,1000010] } }";
            var controller = new ObservationController(mockDb.Object);

            //arrange data to send 1110111_0011101
            var obseq = new ObservationWithSequence();
            observation = new Observation();
            observation.color = "green";
            observation.numbers = new List<string>() { "1110111", "0011101" };
            obseq.sequence = sequence;
            obseq.observation = observation;

            // Act 1
            var actionResult1 = await controller.Add(obseq);

            //arrange data to send 1110111_0010000
            var obseq2 = new ObservationWithSequence();
            var observation2 = new Observation();
            observation2.color = "green";
            observation2.numbers = new List<string>() { "1110111", "0010000" };
            obseq2.sequence = sequence;
            obseq2.observation = observation2;

            // Act 2
            var actionResult2 = await controller.Add(obseq2);

            //arrange data to send RED status
            var obseq3 = new ObservationWithSequence();
            var observation3 = new Observation();
            observation3.color = "red";
            obseq3.sequence = sequence;
            obseq3.observation = observation3;

            //Act 3
            var actionResult3 = await controller.Add(obseq3);

            // Assert
            var statusCodeResult = (IStatusCodeActionResult)actionResult3;
            var response = ((ObjectResult)actionResult3).Value.ToString();
            ;
            Assert.Equal(expectedCode, statusCodeResult.StatusCode);
            Assert.Equal(expectedResponse, response);
        }

        [Fact]
        public async Task Add_send_after_red()
        {
            // Arrange
            var mockDb = new Mock<MyDb>();
            Guid sequence = Guid.NewGuid();
            var observation = new Observation();
            var sd = new SeqData();
            //create sequence
            await mockDb.Object.Set(sequence, sd);
            int expectedCode = 422;
            string expectedResponse = "{ status = error, msg = The�red�observation�should�be�the�last }";
            var controller = new ObservationController(mockDb.Object);

            //arrange data to send 1110111_0011101
            var obseq = new ObservationWithSequence();
            observation = new Observation();
            observation.color = "green";
            observation.numbers = new List<string>() { "1110111", "0011101" };
            obseq.sequence = sequence;
            obseq.observation = observation;

            // Act 1
            var actionResult1 = await controller.Add(obseq);

            //arrange data to send 1110111_0010000
            var obseq2 = new ObservationWithSequence();
            var observation2 = new Observation();
            observation2.color = "green";
            observation2.numbers = new List<string>() { "1110111", "0010000" };
            obseq2.sequence = sequence;
            obseq2.observation = observation2;

            // Act 2
            var actionResult2 = await controller.Add(obseq2);

            //arrange data to send RED status
            var obseq3 = new ObservationWithSequence();
            var observation3 = new Observation();
            observation3.color = "red";
            obseq3.sequence = sequence;
            obseq3.observation = observation3;

            //Act 3
            var actionResult3 = await controller.Add(obseq3);

            //arrange data to send after RED status
            var obseq4 = new ObservationWithSequence();
            var observation4 = new Observation();
            observation4.color = "green";
            observation4.numbers = new List<string>() { "1110111", "0010000" };
            obseq4.sequence = sequence;
            obseq4.observation = observation4;

            //Act 4
            var actionResult4 = await controller.Add(obseq4);

            // Assert
            var statusCodeResult = (IStatusCodeActionResult)actionResult4;
            var response = ((ObjectResult)actionResult4).Value.ToString();
            ;
            Assert.Equal(expectedCode, statusCodeResult.StatusCode);
            Assert.Equal(expectedResponse, response);
        }

        [Fact]
        public async Task Add_no_solutions_found()
        {
            // Arrange
            var mockDb = new Mock<MyDb>();
            Guid sequence = Guid.NewGuid();
            var observation = new Observation();
            var sd = new SeqData();
            //create sequence
            await mockDb.Object.Set(sequence, sd);
            int expectedCode = 422;
            string expectedResponse = "{ status = error, msg = No solutions found }";
            var controller = new ObservationController(mockDb.Object);

            //arrange data to send 1110111_0011101
            var obseq = new ObservationWithSequence();
            observation = new Observation();
            observation.color = "green";
            observation.numbers = new List<string>() { "1110111", "0011101" };
            obseq.sequence = sequence;
            obseq.observation = observation;

            // Act 1
            var actionResult1 = await controller.Add(obseq);

            ////arrange data to send 1110111_0010000
            //var obseq2 = new ObservationWithSequence();
            //var observation2 = new Observation();
            //observation2.color = "green";
            //observation2.numbers = new List<string>() { "1110111", "0010000" };
            //obseq2.sequence = sequence;
            //obseq2.observation = observation2;

            //// Act 2
            //var actionResult2 = await controller.Add(obseq2);

            //arrange data to send RED status
            var obseq3 = new ObservationWithSequence();
            var observation3 = new Observation();
            observation3.color = "red";
            obseq3.sequence = sequence;
            obseq3.observation = observation3;

            //Act 3
            var actionResult3 = await controller.Add(obseq3);

            // Assert
            var statusCodeResult = (IStatusCodeActionResult)actionResult3;
            var response = ((ObjectResult)actionResult3).Value.ToString();
            ;
            Assert.Equal(expectedCode, statusCodeResult.StatusCode);
            Assert.Equal(expectedResponse, response);
        }


        #endregion Constructors

        #region Methods

        [HttpPost("drone")]
        [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(Drone))]
        [ProducesResponseType(StatusCodes.Status412PreconditionFailed)]
        [ProducesResponseType(StatusCodes.Status500InternalServerError)]
        public async Task<IActionResult> RegisterDroneAsync([FromBody] Drone drone)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest();
            }

            try
            {
                return Ok(await service.RegisterDroneAsync(drone));
            }
            catch (DronesReachedMaxNumberInFleetException)
            {
                return new StatusCodeResult(StatusCodes.Status412PreconditionFailed);
            }
            catch (NotUniqueExeption)
            {
                return new StatusCodeResult(StatusCodes.Status412PreconditionFailed);
            }
            catch (Exception)
            {
                return new StatusCodeResult(StatusCodes.Status500InternalServerError);
            }
        }

        [HttpPost("drone/{id}/load")]
        [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(Drone))]
        [ProducesResponseType(StatusCodes.Status404NotFound)]
        [ProducesResponseType(StatusCodes.Status412PreconditionFailed)]
        [ProducesResponseType(StatusCodes.Status500InternalServerError)]
        public async Task<IActionResult> LoadDroneAsync(int id, [FromBody] List<int> medicationItemIds)
        {
            try
            {
                return Ok(await service.LoadDroneAsync(id, medicationItemIds));
            }
            catch (DroneNotFoundException)
            {
                return new StatusCodeResult(StatusCodes.Status404NotFound);
            }
            catch (LowBatteryLevelException)
            {
                return new StatusCodeResult(StatusCodes.Status412PreconditionFailed);
            }
            catch (MedicationItemNotFoundException)
            {
                return new StatusCodeResult(StatusCodes.Status404NotFound);
            }
            catch (DroneOverloadException)
            {
                return new StatusCodeResult(StatusCodes.Status412PreconditionFailed);
            }
            catch (Exception)
            {
                return new StatusCodeResult(StatusCodes.Status500InternalServerError);
            }
        }

        [HttpGet("drone/{id}/medicationitems")]
        [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(MedicationItem))]
        [ProducesResponseType(StatusCodes.Status404NotFound)]
        [ProducesResponseType(StatusCodes.Status500InternalServerError)]
        public async Task<IActionResult> GetLoadedMedicationItemsAsync(int id)
        {
            try
            {
                return Ok(await service.GetLoadedMedicationItemsAsync(id));
            }
            catch (DroneNotFoundException)
            {
                return new StatusCodeResult(StatusCodes.Status404NotFound);
            }
            catch (Exception)
            {
                return new StatusCodeResult(StatusCodes.Status500InternalServerError);
            }
        }

        [HttpGet("drone/available")]
        [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(List<Drone>))]
        [ProducesResponseType(StatusCodes.Status500InternalServerError)]
        public async Task<IActionResult> GetAvailableDrones()
        {
            try
            {
                return Ok(await service.GetAvailableDronesAsync());
            }
            catch (Exception)
            {
                return new StatusCodeResult(StatusCodes.Status500InternalServerError);
            }
        }

        [HttpGet("drone/{id}/batterylevel")]
        [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(decimal))]
        [ProducesResponseType(StatusCodes.Status404NotFound)]
        [ProducesResponseType(StatusCodes.Status500InternalServerError)]
        public async Task<IActionResult> GetBatteryLevelAsync(int id)
        {
            try
            {
                return Ok(await service.GetBatteryLevelAsync(id));
            }
            catch (DroneNotFoundException)
            {
                return new StatusCodeResult(StatusCodes.Status404NotFound);
            }
            catch (Exception)
            {
                return new StatusCodeResult(StatusCodes.Status500InternalServerError);
            }
        }


        [Fact]
        public void Ctor_ControllerDependency_ThrowsArgumentNull_Entity()
        {
            Assert.ThrowsArgumentNull(
                () => new UpdatedODataResult<TestEntity>(entity: null, controller: _controller), "entity");
        }

        [Fact]
        public void Ctor_ControllerDependency_ThrowsArgumentNull_Controller()
        {
            Assert.ThrowsArgumentNull(
                () => new UpdatedODataResult<TestEntity>(_entity, controller: null), "controller");
        }

        [Fact]
        public void Ctor_DirectDependency_ThrowsArgumentNull_Entity()
        {
            Assert.ThrowsArgumentNull(
                () => new UpdatedODataResult<TestEntity>(entity: null, contentNegotiator: _contentNegotiator,
                    request: _request, formatters: _formatters), "entity");
        }

        [Fact]
        public void Ctor_DirectDependency_ThrowsArgumentNull_ContentNegotiator()
        {
            Assert.ThrowsArgumentNull(
                () => new UpdatedODataResult<TestEntity>(_entity, contentNegotiator: null,
                    request: _request, formatters: _formatters), "contentNegotiator");
        }

        [Fact]
        public void Ctor_DirectDependency_ThrowsArgumentNull_Request()
        {
            Assert.ThrowsArgumentNull(
                () => new UpdatedODataResult<TestEntity>(_entity, _contentNegotiator,
                    request: null, formatters: _formatters), "request");
        }

        [Fact]
        public void Ctor_DirectDependency_ThrowsArgumentNull_Formatters()
        {
            Assert.ThrowsArgumentNull(
                () => new UpdatedODataResult<TestEntity>(_entity, _contentNegotiator,
                    _request, formatters: null), "formatters");
        }


        [Fact]
        public void Ctor_ControllerDependency_ThrowsArgumentNull_Entity()
        {
            Assert.ThrowsArgumentNull(
                () => new UpdatedODataResult<TestEntity>(entity: null, controller: _controller), "entity");
        }

        [Fact]
        public void Ctor_ControllerDependency_ThrowsArgumentNull_Controller()
        {
            Assert.ThrowsArgumentNull(
                () => new UpdatedODataResult<TestEntity>(_entity, controller: null), "controller");
        }

        [Fact]
        public void Ctor_DirectDependency_ThrowsArgumentNull_Entity()
        {
            Assert.ThrowsArgumentNull(
                () => new UpdatedODataResult<TestEntity>(entity: null, contentNegotiator: _contentNegotiator,
                    request: _request, formatters: _formatters), "entity");
        }

        [Fact]
        public void Ctor_DirectDependency_ThrowsArgumentNull_ContentNegotiator()
        {
            Assert.ThrowsArgumentNull(
                () => new UpdatedODataResult<TestEntity>(_entity, contentNegotiator: null,
                    request: _request, formatters: _formatters), "contentNegotiator");
        }

        [Fact]
        public void Ctor_DirectDependency_ThrowsArgumentNull_Request()
        {
            Assert.ThrowsArgumentNull(
                () => new UpdatedODataResult<TestEntity>(_entity, _contentNegotiator,
                    request: null, formatters: _formatters), "request");
        }

        [Fact]
        public void Ctor_DirectDependency_ThrowsArgumentNull_Formatters()
        {
            Assert.ThrowsArgumentNull(
                () => new UpdatedODataResult<TestEntity>(_entity, _contentNegotiator,
                    _request, formatters: null), "formatters");
        }


        [Route("error")]
        [AllowAnonymous]
        public IActionResult Error()
        {
            var exceptionHandlerPathFeature = HttpContext.Features.Get<IExceptionHandlerFeature>();

            //ViewBag.ExceptionPath = ((ExceptionHandlerFeature)exceptionHandlerPathFeature).Path;
            //ViewBag.ErrorMessage = exceptionHandlerPathFeature.Error.Message;
            //ViewBag.StackTrace = exceptionHandlerPathFeature.Error.StackTrace;

            _logger.LogError($"路径{((ExceptionHandlerFeature)exceptionHandlerPathFeature).Path},产生了一个错误:{exceptionHandlerPathFeature.Error.Message}");

            return View("Error");
        }

        [Route("error/{statusCode}")]
        public IActionResult HttpStatusCodeHandler(int statusCode)
        {
            var statusCodeResult = HttpContext.Features.Get<IStatusCodeReExecuteFeature>();

            //ViewBag.Path = statusCodeResult.OriginalPath;
            //ViewBag.QueryString = statusCodeResult.OriginalQueryString;

            switch (statusCode)
            {
                case StatusCodes.Status404NotFound:
                default:
                    ViewBag.ErrorMessage = "抱歉,用户访问的页面不存在";

                    _logger.LogError($"发生了一个404错误,路径{statusCodeResult.OriginalPath + statusCodeResult.OriginalQueryString}");
                    return View("NotFound");
            }
        }



        [HttpGet("{id}")]
        [ResponseCache(NoStore = true, Location = ResponseCacheLocation.None)]
        [ProducesResponseType(StatusCodes.Status200OK)]
        [ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status404NotFound)]
        [ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status500InternalServerError)]
        public async Task<IActionResult> Get([FromRoute] string id)
        {
            _logger.LogInformation($"Getting image with id - {id}");

            var loadImageResult = await _imageStorageService.LoadImageAsync(id);
            if (loadImageResult.IsSuccess)
            {
                _logger.LogInformation($"Getting image with id - {id} success");

                return File(loadImageResult.Value.File, loadImageResult.Value.FileMediaType);
            }

            var statusCodeResult = GetImageLoadErrorResult(loadImageResult.ErrorType);
            _logger.LogWarning(statusCodeResult.StatusCode.HasValue
                ? $"Getting image with id - {id} failed; Status code - {statusCodeResult.StatusCode.Value}, reason - {statusCodeResult.Value}"
                : $"Getting image with id - {id} failed; Reason - {statusCodeResult.Value}");

            return statusCodeResult;
        }

        [HttpPost("upload")]
        [Authorize]
        [ProducesResponseType(typeof(SavedImageDataResponse), StatusCodes.Status200OK)]
        [ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status400BadRequest)]
        [ProducesResponseType(StatusCodes.Status401Unauthorized)]
        [ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status500InternalServerError)]
        public async Task<ActionResult<SavedImageDataResponse>> UploadImage(IFormFile image)
        {
            if (image == null)
            {
                return BadRequest();
            }
            _logger.LogInformation($"Uploading new image with name - {image.Name}");

            var imageStream = image.OpenReadStream();
            var saveImageResult = await _imageStorageService.SaveImageAsync(image.FileName, imageStream);
            if (!saveImageResult.IsSuccess)
            {
                var statusCodeResult = GetImageSaveErrorResult(saveImageResult.ErrorType);
                _logger.LogWarning(statusCodeResult.StatusCode.HasValue
                    ? $"Uploading new image with name - {image.Name} failed; Status code - {statusCodeResult.StatusCode.Value}, reason - {statusCodeResult.Value}"
                    : $"Uploading new image with name - {image.Name} failed; Reason - {statusCodeResult.Value}");

                return statusCodeResult;
            }

            var imageUrl = GetImageUrl(saveImageResult.Value.ExternalId);
            var dataContract = new SavedImageDataResponse
            {
                Url = imageUrl,
                ExternalId = saveImageResult.Value.ExternalId
            };
            _logger.LogInformation($"Uploading new image with name - {image.Name} success");

            return dataContract;
        }



        private string GetImageUrl(string externalId)
        {
            return Url.Action(nameof(Get), "Images", new { id = externalId }, Request.Scheme);
        }

        private ObjectResult GetImageLoadErrorResult(LoadImageError error)
        {
            return error switch
            {
                LoadImageError.IncorrectExternalId => NotFound(new ErrorResponse("Incorrect image id")),
                LoadImageError.ImageNotExists => StatusCode(500, new ErrorResponse("Internal error. Image wasn't found")),
                _ => throw new ArgumentOutOfRangeException(nameof(error), error, null),
            };
        }

        private ObjectResult GetImageSaveErrorResult(SaveImageError errorType)
        {
            return errorType switch
            {
                SaveImageError.EmptyFilePath => BadRequest(new ErrorResponse("Empty filepath")),
                SaveImageError.TooBigImage => BadRequest(new ErrorResponse("Too big image")),
                SaveImageError.NotAllowedMediaType => BadRequest(new ErrorResponse("Not allowed media type")),
                SaveImageError.StorageError => StatusCode(500, new ErrorResponse("Internal error. Image can't be uploaded")),
                _ => throw new ArgumentOutOfRangeException(nameof(errorType), errorType, null),
            };
        }

        [Fact]
        public void Constructor_Throws_WhenRequestIsNull()
        {
            // Arrange
            HttpStatusCode statusCode = CreateStatusCode();
            HttpRequestMessage request = null;

            // Act & Assert
            Assert.ThrowsArgumentNull(() => { new StatusCodeResult(statusCode, request); }, "request");
        }

        [Fact]
        public void StatusCode_Returns_ValueProvided()
        {
            // Arrange
            HttpStatusCode expectedStatusCode = CreateStatusCode();

            using (HttpRequestMessage request = CreateRequest())
            {
                StatusCodeResult result = new StatusCodeResult(expectedStatusCode, request);

                // Act
                HttpStatusCode statusCode = result.StatusCode;

                // Assert
                Assert.Equal(expectedStatusCode, statusCode);
            }
        }

        [Fact]
        public void Request_Returns_InstanceProvided()
        {
            // Arrange
            HttpStatusCode statusCode = CreateStatusCode();

            using (HttpRequestMessage expectedRequest = CreateRequest())
            {
                StatusCodeResult result = new StatusCodeResult(statusCode, expectedRequest);

                // Act
                HttpRequestMessage request = result.Request;

                // Assert
                Assert.Same(expectedRequest, request);
            }
        }

        [Fact]
        public void ExecuteAsync_Returns_CorrectResponse()
        {
            // Arrange
            HttpStatusCode expectedStatusCode = CreateStatusCode();

            using (HttpRequestMessage expectedRequest = CreateRequest())
            {
                IHttpActionResult result = new StatusCodeResult(expectedStatusCode, expectedRequest);

                // Act
                Task<HttpResponseMessage> task = result.ExecuteAsync(CancellationToken.None);

                // Assert
                Assert.NotNull(task);
                task.WaitUntilCompleted();

                using (HttpResponseMessage response = task.Result)
                {
                    Assert.NotNull(response);
                    Assert.Equal(expectedStatusCode, response.StatusCode);
                    Assert.Same(expectedRequest, response.RequestMessage);
                }
            }
        }

        [Fact]
        public void Constructor_ForApiController_Throws_WhenControllerIsNull()
        {
            // Arrange
            HttpStatusCode statusCode = CreateStatusCode();
            ApiController controller = null;

            // Act & Assert
            Assert.ThrowsArgumentNull(() => { new StatusCodeResult(statusCode, controller); }, "controller");
        }

        [Fact]
        public void ExecuteAsync_ForApiController_ReturnsCorrectResponse()
        {
            // Arrange
            HttpStatusCode expectedStatusCode = CreateStatusCode();
            ApiController controller = CreateController();

            using (HttpRequestMessage expectedRequest = CreateRequest())
            {
                controller.Request = expectedRequest;
                IHttpActionResult result = new StatusCodeResult(expectedStatusCode, controller);

                // Act
                Task<HttpResponseMessage> task = result.ExecuteAsync(CancellationToken.None);

                // Assert
                Assert.NotNull(task);
                task.WaitUntilCompleted();

                using (HttpResponseMessage response = task.Result)
                {
                    Assert.NotNull(response);
                    Assert.Equal(expectedStatusCode, response.StatusCode);
                    Assert.Same(expectedRequest, response.RequestMessage);
                }
            }
        }

Microsoft.AspNetCore.Mvc.StatusCodeResult : IActionResult

Constructors :

public StatusCodeResult(Int32 statusCode = )

Methods :

public Int32 get_StatusCode()
public Void ExecuteResult(ActionContext context = )
public Task ExecuteResultAsync(ActionContext context = )
public Type GetType()
public String ToString()
public Boolean Equals(Object obj = )
public Int32 GetHashCode()

Other methods