public static async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, "put", Route = "contests/numberoflearners")] HttpRequest req,
            [Queue("contestnumberoflearners-update", Connection = "AzureStorageOptions:ConnectionString")] ICollector <ContestNumberOfLearnersUpdate> contestNumberOfLearnersUpdates,
            ILogger log)
        {
            log.LogInformation("C# HTTP trigger function processed a request.");

            var contestLister =
                new ContestLister(
                    ObjectFactory.CreateMapper(),
                    ObjectFactory.CreateContestRepository());

            var contests =
                await contestLister.ExecuteAsync(
                    new ContestList());

            foreach (var contest in contests)
            {
                var contestNumberOfLearnersUpdate =
                    new ContestNumberOfLearnersUpdate
                {
                    ContestId = contest.Id
                };

                log.LogInformation(
                    JsonConvert.SerializeObject(contestNumberOfLearnersUpdate, Formatting.Indented));

                contestNumberOfLearnersUpdates.Add(
                    contestNumberOfLearnersUpdate);
            }

            return(new OkResult());
        }
        public static async Task Run(
            [QueueTrigger("contestnumberoflearners-update", Connection = "AzureStorageOptions:ConnectionString")] ContestNumberOfLearnersUpdate contestNumberOfLearnersUpdate,
            ILogger log)
        {
            log.LogInformation(
                JsonConvert.SerializeObject(contestNumberOfLearnersUpdate, Formatting.Indented));

            var contestNumberOfLearnersUpdater =
                new ContestNumberOfLearnersUpdater(
                    ObjectFactory.CreateContestRepository(),
                    ObjectFactory.CreateContestLearnerRepository());

            var contestNumberOfLearnersUpdated =
                await contestNumberOfLearnersUpdater.ExecuteAsync(
                    contestNumberOfLearnersUpdate);

            log.LogInformation(
                JsonConvert.SerializeObject(contestNumberOfLearnersUpdated, Formatting.Indented));
        }
        public static void Run(
            [QueueTrigger("contestlearner-added", Connection = "AzureStorageOptions:ConnectionString")] ContestLearnerAdded contestLearnerAdded,
            [Queue("contestnumberoflearners-update", Connection = "AzureStorageOptions:ConnectionString")] ICollector <ContestNumberOfLearnersUpdate> contestNumberOfLearnersUpdates,
            ILogger log)
        {
            log.LogInformation(
                JsonConvert.SerializeObject(contestLearnerAdded, Formatting.Indented));

            var contestNumberOfLearnersUpdate =
                new ContestNumberOfLearnersUpdate
            {
                ContestId = contestLearnerAdded.ContestId
            };

            log.LogInformation(
                JsonConvert.SerializeObject(contestNumberOfLearnersUpdate, Formatting.Indented));

            contestNumberOfLearnersUpdates.Add(
                contestNumberOfLearnersUpdate);
        }