Exemple #1
0
        /// <summary>
        /// Get all the unique identifiers of the commands that match the input request settings
        /// </summary>
        private static async Task <IEnumerable <string> > AllLeaguesIdentifierGroupProcess(
            LeaguesIdentifierGroup_Request request,
            ILogger log)
        {
            #region Logging
            if (null != log)
            {
                log.LogInformation($"Creating identifier group processor for leagues");
            }
            #endregion

            #region Input validations
            // If as of date is stupid, clear it
            if (request.AsOfDate.HasValue)
            {
                if (request.AsOfDate.Value.Year < 2000)
                {
                    request.AsOfDate = null;
                }
            }
            #endregion

            IdentifierGroup allLeagues = new IdentifierGroup("Leagues",
                                                             "League",
                                                             "All leagues");

            if (null != allLeagues)
            {
                return(await allLeagues.GetAll(request.AsOfDate));
            }
            else
            {
                return(Enumerable.Empty <string>());
            }
        }
Exemple #2
0
        public static async Task <IEnumerable <string> > GetAllLeaguesIdentifierGroupActivity(
            [ActivityTrigger] DurableActivityContext context,
            ILogger log)
        {
            LeaguesIdentifierGroup_Request request = context.GetInput <LeaguesIdentifierGroup_Request>();

            #region Logging
            if (null != log)
            {
                log.LogInformation($"GetAllLeaguesIdentifierGroupActivity called as of {request.AsOfDate}");
            }
            #endregion

            return(await AllLeaguesIdentifierGroupProcess(request, log));
        }
Exemple #3
0
        public static async Task <HttpResponseMessage> GetAllLeaguesIdentifierGroupRun(
            [HttpTrigger(AuthorizationLevel.Function, "get", Route = null)] HttpRequestMessage req,
            ILogger log)
        {
            #region Logging
            if (null != log)
            {
                log.LogDebug("Function triggered HTTP in GetAllLeaguesIdentifierGroup");
            }
            #endregion

            string   asOfDateString = req.RequestUri.ParseQueryString()["AsOfDate"];
            DateTime?asOfDate       = null;
            if (!string.IsNullOrWhiteSpace(asOfDateString))
            {
                DateTime dtOut;
                if (DateTime.TryParse(asOfDateString, out dtOut))
                {
                    asOfDate = dtOut;
                }
            }

            if (!asOfDate.HasValue)
            {
                // Get request body
                AllCommandsIdentifierGroup_Request data = await req.Content.ReadAsAsync <AllCommandsIdentifierGroup_Request>();

                if (null != data)
                {
                    asOfDate = data.AsOfDate;
                }
            }

            LeaguesIdentifierGroup_Request request = new LeaguesIdentifierGroup_Request()
            {
                AsOfDate = asOfDate
            };


            IEnumerable <string> ret = await AllLeaguesIdentifierGroupProcess(request, log);

            return(req.CreateResponse(HttpStatusCode.OK, ret,
                                      new System.Net.Http.Formatting.JsonMediaTypeFormatter()));
        }