Exemplo n.º 1
0
        public async Task <string> AddUserMessage(string userId, int messageType, string serviceId, string username = "")
        {
            try
            {
                UserMessage message = null;
                if (messageType == (int)MessageType.NewOrder)
                {
                    message = PrepareNewOrderMessage(userId, serviceId);
                }
                else if (messageType == (int)MessageType.OrderAcknowledge)
                {
                    message = PrepareAcknowledgeOrderMessage(userId, serviceId);
                }
                else if (messageType == (int)MessageType.ConfirmOrder)
                {
                    message = PrepareConfirmOrderMessage(userId, serviceId);
                }
                else if (messageType == (int)MessageType.ConfirmOrderDobi)
                {
                    message = PrepareConfirmDobiOrderMessage(userId, serviceId, username);
                }
                if (message == null)
                {
                    return(null);
                }
                var ack = await _userMessageRepository.AddUserMessage(message);

                if (!ack)
                {
                    return(null);
                }
                return(message.MessageId);
            }
            catch (Exception ex)
            {
                throw new Exception("Error adding user message" + ex);
            }
        }