Пример #1
0
        public async Task <Ticket> AddNewTicket(TicketCreateCommand positionCreateCommand, CancellationToken cancellationToken)
        {
            var    ticketdetails = _mapper.Map <Ticket>(positionCreateCommand);
            Random rn            = new Random(10000000);

            ticketdetails.Id          = rn.Next().ToString();
            ticketdetails.Ticketid    = "T" + rn.Next().ToString();
            ticketdetails.CreatedDate = DateTime.Now;
            ticketdetails.Status      = "Open";
            ticketdetails.AssignTo    = new Recruiter()
            {
                Name = "Nathan S"
            };
            _databaseContext.Tickets.Add(ticketdetails);
            //_databaseContext.SaveChanges();
            await _databaseContext.SaveChangesAsync(cancellationToken);

            //await _notificationService.NotifyRecruiterAboutNewOpenPosition(ticketdetails, cancellationToken);

            return(ticketdetails);
        }
        private async Task <ComposeExtensionResponse> CreateResponseToConfirmCreatePostingCommand(TicketCreateCommand data)
        {
            var position = await _positionService.GetById(data.Id);

            var extensionAttachment = _mapper.Map <ComposeExtensionAttachment>(position);

            return(new ComposeExtensionResponse
            {
                ComposeExtension = new ComposeExtensionResult
                {
                    AttachmentLayout = AttachmentLayoutTypes.List,
                    Type = "result",
                    Attachments = new List <ComposeExtensionAttachment>
                    {
                        extensionAttachment
                    }
                }
            });
        }
        private async Task <TaskModuleResponseEnvelope> CreateConfirmJobPostingTaskModuleResponse(TicketCreateCommand positionCreateCommand, CancellationToken cancellationToken)
        {
            var position = await _positionService.AddNewTicket(positionCreateCommand, cancellationToken);

            positionCreateCommand.CommandId = AppCommands.ConfirmCreationOfNewPosition;
            positionCreateCommand.Ticketid  = position.Ticketid;

            var card = _mapper.Map <AdaptiveCard>(position);

            card.Actions = new List <AdaptiveAction>
            {
                new AdaptiveSubmitAction
                {
                    Title = "Confirm posting",
                    Data  = positionCreateCommand
                },
                new AdaptiveSubmitAction
                {
                    Title = "Cancel"
                }
            };

            return(new TaskModuleResponseEnvelope
            {
                Task = new TaskModuleContinueResponse
                {
                    Type = "continue",
                    Value = new TaskModuleTaskInfo
                    {
                        Card = card.ToAttachment(),
                        Title = "Confirm new posting",
                        Width = "medium",
                        Height = "medium"
                    }
                }
            });
        }