示例#1
0
        public async Task <IActionResult> SignIn([FromServices] EventsContext eventsContext, [FromServices] BlobContext blobContext, int id)
        {
            var eventItem = await eventsContext.Events.SingleOrDefaultAsync(e => e.Id == id);

            SignInSheetState signInSheetState = default(SignInSheetState);

            if (String.IsNullOrEmpty(eventItem.SignInDocumentUrl))
            {
                using (Stream stream = new MemoryStream())
                {
                    await blobContext.UploadBlobAsync($"{eventItem.EventKey}.docx", stream);
                }
                eventItem.SignInDocumentUrl = PROCESSING_URI;
                await eventsContext.SaveChangesAsync();

                signInSheetState = SignInSheetState.SignInDocumentProcessing;
            }
            else if (eventItem.SignInDocumentUrl == PROCESSING_URI)
            {
                signInSheetState = SignInSheetState.SignInDocumentProcessing;
            }
            else
            {
                signInSheetState = SignInSheetState.SignInDocumentAlreadyExists;
            }

            SignInSheetViewModel viewModel = new SignInSheetViewModel
            {
                Event            = eventItem,
                SignInSheetState = signInSheetState
            };

            return(View(viewModel));
        }
        public async Task <IActionResult> SignIn([FromServices] EventsContext eventsContext, [FromServices] QueueContext queueContext, int id)
        {
            var eventItem = await eventsContext.Events.SingleOrDefaultAsync(e => e.Id == id);

            SignInSheetState signInSheetState = default(SignInSheetState);

            if (String.IsNullOrEmpty(eventItem.SignInDocumentUrl))
            {
                await queueContext.SendQueueMessageAsync(eventItem.EventKey);

                eventItem.SignInDocumentUrl = PROCESSING_URI;
                await eventsContext.SaveChangesAsync();

                signInSheetState = SignInSheetState.SignInDocumentProcessing;
            }
            else if (eventItem.SignInDocumentUrl == PROCESSING_URI)
            {
                signInSheetState = SignInSheetState.SignInDocumentProcessing;
            }
            else
            {
                signInSheetState = SignInSheetState.SignInDocumentAlreadyExists;
            }

            SignInSheetViewModel viewModel = new SignInSheetViewModel
            {
                Event            = eventItem,
                SignInSheetState = signInSheetState
            };

            return(View(viewModel));
        }
示例#3
0
        private void GenerateSignInSheetStorageQueues(EventsContext context, Event eventItem, string message)
        {
            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(storageConnectionString);
            CloudQueueClient    queueClient    = storageAccount.CreateCloudQueueClient();

            CloudQueue queue = queueClient.GetQueueReference(signInQueueName);

            queue.CreateIfNotExists();

            CloudQueueMessage queueMessage = new CloudQueueMessage(message);

            queue.AddMessage(queueMessage);

            eventItem.SignInDocumentUrl = PROCESSING_URI;

            context.SaveChanges();

            this.Event = eventItem;

            this.SignInSheetState = SignInSheetState.SignInDocumentProcessing;
        }