Пример #1
0
        public async Task <IActionResult> Out([FromBody] PayloadModel <OutMessage> model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var contact = await peopleRepository.GetContactByPeopleId(model.AgentId);

            switch (model.Message.DetermineMessageType())
            {
            case MessageType.Text:
                await sendMessageService.SendTextMessageAsync(model.BotId, contact.InfoTextId, model.Message);

                break;

            case MessageType.Picture:
                await sendMessageService.SendPictureMessageAsync(model.BotId, contact.InfoTextId, model.Message);

                break;

            case MessageType.Location:
                await sendMessageService.SendLocationMessageAsync(model.BotId, contact.InfoTextId, model.Message);

                break;

            case MessageType.RichMedia:
                await sendMessageService.SendRichMediaMessageAsync(model.BotId, contact.InfoTextId, model.Message);

                break;

            case MessageType.Keyboard:
                await sendMessageService.SendKeyboardMessageAsync(model.BotId, contact.InfoTextId, model.Message);

                break;
            }

            return(Ok());
        }