Beispiel #1
0
        /// <summary>
        /// process, add new authority for...
        /// submission choices...
        /// {"LADCode": "E00060060", "Name": "Widdicombe Sands" }
        /// {"TouchpointID":"0000000102", "LADCode": "E00060060", "Name": "Widdicombe Sands" }
        /// </summary>
        /// <param name="theTouchpoint">the touchpoint</param>
        /// <param name="usingContent">using content</param>
        /// <param name="inScope">in scope</param>
        /// <returns>the result of the operation</returns>
        public async Task <HttpResponseMessage> ProcessAddNewAuthorityFor(
            string theTouchpoint,
            string usingContent,
            IScopeLoggingContext inScope)
        {
            await inScope.EnterMethod();

            It.IsEmpty(theTouchpoint)
            .AsGuard <ArgumentNullException>(nameof(theTouchpoint));
            It.IsEmpty(usingContent)
            .AsGuard <ArgumentNullException>(nameof(usingContent));

            await inScope.Information($"deserialising the submitted content: '{usingContent}'");

            var theCandidate = JsonConvert.DeserializeObject <IncomingLocalAuthority>(usingContent);

            It.IsNull(theCandidate)
            .AsGuard <MalformedRequestException>(nameof(ILocalAuthority.LADCode));

            await inScope.Information("deserialisation complete...");

            if (It.IsEmpty(theCandidate.TouchpointID))
            {
                await inScope.Information($"applying missing touchpoint details: '{theTouchpoint}'");

                theCandidate.TouchpointID = theTouchpoint;
            }

            await inScope.Information($"validating the candidate: '{theCandidate.LADCode}'");

            await Authority.Validate(theCandidate);

            await inScope.Information($"validation complete...");

            await inScope.Information($"adding the candidate: '{theCandidate.LADCode}'");

            var result = await Authorities.Add(theCandidate);

            await inScope.Information($"candidate addition complete...");

            await inScope.Information($"preparing response...");

            var response = Respond.Created().SetContent(result);

            await inScope.Information($"preparation complete...");

            await inScope.ExitMethod();

            return(response);
        }
        /// <summary>
        /// process, add new area routing detail
        /// </summary>
        /// <param name="theTouchpoint">the touchpoint</param>
        /// <param name="usingContent">using content</param>
        /// <param name="inScope">in scope</param>
        /// <returns>the result of the operation</returns>
        public async Task <HttpResponseMessage> ProcessAddAreaRoutingDetailUsing(
            string theContent,
            IScopeLoggingContext inScope)
        {
            await inScope.EnterMethod();

            It.IsEmpty(theContent)
            .AsGuard <MalformedRequestException>();

            await inScope.Information($"deserialising the submitted content: '{theContent}'");

            var theCandidate = JsonConvert.DeserializeObject <IncomingRoutingDetail>(theContent);

            await inScope.Information("deserialisation complete...");

            It.IsNull(theCandidate)
            .AsGuard <MalformedRequestException>();

            await inScope.Information($"validating the candidate: '{theCandidate.TouchpointID}'");

            await RoutingDetail.Validate(theCandidate);

            await inScope.Information($"validation complete...");

            await inScope.Information($"adding the candidate: '{theCandidate.TouchpointID}'");

            var result = await RoutingDetails.Add(theCandidate);

            await inScope.Information($"candidate addition complete...");

            await inScope.Information($"preparing response...");

            var response = Respond.Created().SetContent(result);

            await inScope.Information($"preparation complete...");

            await inScope.ExitMethod();

            return(response);
        }