Esempio n. 1
0
        public static IActionResult Run(
            [HttpTrigger(AuthorizationLevel.Function, "POST", Route = null)]
            HttpRequest httpRequest,
            TraceWriter traceWriter)
        {
            IActionResult toReturn = null;

            LoggerProvider loggerProvider = new LoggerProvider(traceWriter);

            toReturn = FunctionLogicHarness.Execute <Models.UpdatePersonBody.Person>(
                httpRequest,
                new LoggerProvider(traceWriter),
                PerformPersonValidation,
                PerformUpdatePerson);

            return(toReturn);
        }
Esempio n. 2
0
        private static bool PerformPersonValidation(
            ILoggerProvider loggerProvider,
            Models.UpdatePersonBody.Person person)
        {
            bool passedValidation = true;

            // The top level is validated for free.
            // If the top level passed, now validate the sub-properties.
            if (passedValidation && (person.Consent != null))
            {
                passedValidation = FunctionLogicHarness.ValidateModel(
                    loggerProvider,
                    person.Consent);
            }

            // ContactDetail is required, whilst the others are optional.
            // We need ContactDetail because it contains the key we use to
            // look up a person.
            if (passedValidation)
            {
                passedValidation = FunctionLogicHarness.ValidateModel(
                    loggerProvider,
                    person.ContactDetail);
            }

            if (passedValidation && (person.Cookie != null))
            {
                passedValidation = FunctionLogicHarness.ValidateModel(
                    loggerProvider,
                    person.Cookie);
            }

            if (passedValidation && (person.Cookie != null))
            {
                passedValidation = FunctionLogicHarness.ValidateModel(
                    loggerProvider,
                    person.Route);
            }

            return(passedValidation);
        }
Esempio n. 3
0
        private static bool PerformPersonValidation(
            ILoggerProvider loggerProvider,
            Models.CreatePersonBody.Person person)
        {
            bool passedValidation = true;

            // The top level is validated for free.
            // If the top level passed, now validate the sub-properties.
            if (passedValidation)
            {
                passedValidation = FunctionLogicHarness.ValidateModel(
                    loggerProvider,
                    person.Consent);
            }

            if (passedValidation)
            {
                passedValidation = FunctionLogicHarness.ValidateModel(
                    loggerProvider,
                    person.ContactDetail);
            }

            if (passedValidation)
            {
                passedValidation = FunctionLogicHarness.ValidateModel(
                    loggerProvider,
                    person.Cookie);
            }

            if (passedValidation)
            {
                passedValidation = FunctionLogicHarness.ValidateModel(
                    loggerProvider,
                    person.Route);
            }

            return(passedValidation);
        }