コード例 #1
0
        private async Task ExternalCallBack(CommandReadDto cmd, ITurnContext turnContext, CancellationToken cancellationToken)
        {
            var Name  = cmd.Name;
            var Email = cmd.Email;

            await turnContext.SendActivityAsync(MessageFactory.Attachment(getJson(Name, Email)));
        }
コード例 #2
0
        public async Task <ActionResult <CommandReadDto> > CreateCommand(CommandCreateDto commandCreateDto)
        {
            Command command = _mapper.Map <Command>(commandCreateDto);
            await _repository.CreateCommand(command);

            CommandReadDto commandReadDto = _mapper.Map <CommandReadDto>(command);

            return(CreatedAtRoute(nameof(GetCommandById), new { Id = commandReadDto.Id }, commandReadDto));
        }
コード例 #3
0
        public ActionResult <CommandReadDto> CreateCommand(CommandCreateDto commandCreateDto)
        {
            Command command = mapper.Map <Command>(commandCreateDto);

            repository.CreateCommand(command);
            repository.SaveChanges();
            CommandReadDto commandReadDto = mapper.Map <CommandReadDto>(command);

            return(CreatedAtRoute(nameof(GetCommandById), new { Id = commandReadDto.Id }, commandReadDto));
        }
コード例 #4
0
        public async Task <IActionResult> ExternalCalling(CommandReadDto cmd)
        {
            foreach (var item in _conversationReferences.Values)
            {
                await((BotAdapter)Adapter).ContinueConversationAsync("69a8feb2-ff59-4606-b4ae-9c9a73f0676f", item, async(Context, Token) => await ExternalCallBack(cmd, Context, Token), default(CancellationToken));
            }
            var con = new ContentResult();

            con.StatusCode = (int)HttpStatusCode.OK;
            return(con);
        }
コード例 #5
0
        public async Task <IActionResult> ExternalCalling(CommandReadDto cmd)
        {
            foreach (var item in _conversationReferences.Values)
            {
                await((BotAdapter)Adapter).ContinueConversationAsync("cad35b6c-bdaf-4583-8e19-a680cc500b06", item, async(Context, Token) => await ExternalCallback(cmd, Context, Token), default(CancellationToken));
            }
            var con = new ContentResult();

            con.StatusCode = (int)HttpStatusCode.OK;
            return(con);
        }
コード例 #6
0
        public ActionResult <CommandReadDto> CreateCommand([FromBody] CommandCreateDto cmd)
        {
            Command commandModel = _mapper.Map <Command>(cmd);

            _repo.CreateCommand(commandModel);
            _repo.SaveChanges();

            CommandReadDto commandReadDto = _mapper.Map <CommandReadDto>(commandModel);

            return(CreatedAtRoute(nameof(GetCommandById), new { commandReadDto.Id }, commandReadDto));
        }
コード例 #7
0
        public ActionResult <CommandReadDto> CreateCommand(CommandReadDto commandCreateDto)
        {
            var coommandModel = _mapper.Map <Command>(commandCreateDto);

            _repository.CreateCommand(coommandModel);
            _repository.SaveChanges();

            var commandReadDto = _mapper.Map <CommandReadDto>(coommandModel);


            return(CreatedAtRoute(nameof(GetCommandById), new { Id = CommandReadDto.Id }, commandReadDto));
        }
コード例 #8
0
        public ActionResult <CommandReadDto> GetCommandById(int id)
        {
            Command commandItem = _repository.GetCommandById(id);

            if (commandItem == null)
            {
                return(NotFound());
            }

            CommandReadDto test = _mapper.Map <CommandReadDto>(commandItem);

            return(Ok(test));
        }
コード例 #9
0
        public async Task <ActionResult <Command> > ReplaceCommand(int?id, CommandReadDto cmd)

        {
            if (cmd.Description == null || cmd.Name == null || id == null)
            {
                return(BadRequest());
            }
            var sql      = "update commands Set name = @Name, description = @Description where Id=@id";
            var inserted = await _data.SaveData(sql, new { Name = cmd.Name, Description = cmd.Description, Id = id }, _connectionString);

            if (inserted == 1)
            {
                return(NoContent());
            }

            return(NotFound());
        }
コード例 #10
0
        public async Task <ActionResult <Command> > CreateCommand(CommandReadDto cmd)

        {
            if (cmd.Description == null || cmd.Name == null)
            {
                return(BadRequest());
            }
            var sql      = "insert into commands (name,description) values(@Name,@Description)";
            var inserted = await _data.SaveData(sql, new { Name = cmd.Name, Description = cmd.Description }, _connectionString);

            if (inserted == 1)
            {
                return(CreatedAtRoute(nameof(GetCommandById), new { Inserted = true }));
            }

            return(BadRequest());
        }
コード例 #11
0
        public async Task <ActionResult <CommandReadDto> > CreateCommand([FromBody] CommandCreateDto cmd)
        {
            Command newCommand = _mapper.Map <Command>(cmd);

            await Task.Run(() => _commandAPIRepo.CreateCommand(newCommand));

            await Task.Run(() => _commandAPIRepo.SaveChanges());

            CommandReadDto createdCommand = _mapper.Map <CommandReadDto>(newCommand);

            //return Created("Success", new { data = createdCommand });

            return(
                CreatedAtRoute(
                    nameof(GetCommandById),
                    new { Id = createdCommand.Id },
                    new { data = createdCommand }
                    )
                );
        }