コード例 #1
0
            public Task <Unit> Handle(Query message)
            {
                var code = _context.Documents.Where(d => d.Id.Equals(message.DocumentId)).Select(d => d.Type.Code)
                           .SingleOrDefault();

                var input = _context.DocumentUserInputs.SingleOrDefault(ui => ui.DocumentId.Equals(message.DocumentId));
                var dto   = JsonConvert.DeserializeObject <UserInputDto>(input.UserInput);

                var documentGenerator = _templateGeneratorFactory.Create(code);
                var generatedDocument = documentGenerator.Process(new Dictionary <string, object>
                {
                    { "UserId", message.UserId },
                    { "RequestId", message.OwnerId },
                    { "DocumentId", message.DocumentId },
                    { "UserInputFields", dto.Fields },
                    { "SelectedRequestIds", dto.SelectedRequestIds },
                    { "PageCount", dto.PageCount }
                });

                _notificationSender.ProcessEmailAsync(generatedDocument, message.DocumentId).Wait();
                //_context.SaveChangesAsync().Wait();

                //var notificationStatuses = _context.DocumentNotificationStatuses
                //    .Include(ds => ds.NotificationStatus)
                //    .Where(dn => dn.DocumentId.Equals(message.DocumentId))
                //    .Select(dn => dn.NotificationStatus);

                return(Unit.Task);
            }