public FundingStreamPeriodProfilePatternDocument(FundingStreamPeriodProfilePattern pattern)
 {
     logged = System.DateTime.Now;
     id     = pattern.FundingStreamPeriodCode;
     FundingStreamPeriodCode      = pattern.FundingStreamPeriodCode;
     FundingStreamPeriodStartDate = pattern.FundingStreamPeriodStartDate;
     FundingStreamPeriodEndDate   = pattern.FundingStreamPeriodEndDate;
     ReprofilePastPeriods         = pattern.ReprofilePastPeriods;
     ProfilePattern = pattern.ProfilePattern;
 }
        public static async Task <HttpResponseMessage> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "FundingProfilePatterns/FundingStreamPeriod")] FundingStreamPeriodProfilePattern fundingStreamPeriodPatternRequest
            , HttpRequestMessage req
            , [DocumentDB("FundingPolicy", "FundingStreamPeriodProfilePattern", ConnectionStringSetting = "CosmosDB")] IAsyncCollector <object> outputDocument
            , TraceWriter log)
        {
            log.Info($"C# HTTP trigger function processed a request to create funding profile pattern for {fundingStreamPeriodPatternRequest.FundingStreamPeriodCode}");
            var doc = new FundingStreamPeriodProfilePatternDocument(fundingStreamPeriodPatternRequest);

            log.Verbose("Outgoing funding stream code::" + doc.FundingStreamPeriodCode);
            await outputDocument.AddAsync(doc);

            if (doc.FundingStreamPeriodCode != " ")
            {
                return(req.CreateResponse(HttpStatusCode.OK, $"{doc.FundingStreamPeriodCode} was created"));
            }
            else
            {
                return(req.CreateResponse(HttpStatusCode.BadRequest,
                                          $"The request was incorrectly formatted."));
            }
        }